diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 32103692421..8b61d8686cd 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -176,33 +176,33 @@ set(SRC engines/gpencil/gpencil_shader_fx.c engines/select/select_draw_utils.c engines/select/select_engine.c - engines/overlay/overlay_antialiasing.c - engines/overlay/overlay_armature.c - engines/overlay/overlay_background.c - engines/overlay/overlay_edit_curve.c + engines/overlay/overlay_antialiasing.cc + engines/overlay/overlay_armature.cc + engines/overlay/overlay_background.cc + engines/overlay/overlay_edit_curve.cc engines/overlay/overlay_edit_curves.cc - engines/overlay/overlay_edit_mesh.c - engines/overlay/overlay_edit_text.c - engines/overlay/overlay_edit_uv.c - engines/overlay/overlay_engine.c - engines/overlay/overlay_extra.c - engines/overlay/overlay_facing.c - engines/overlay/overlay_fade.c - engines/overlay/overlay_gpencil.c - engines/overlay/overlay_grid.c - engines/overlay/overlay_image.c - engines/overlay/overlay_lattice.c - engines/overlay/overlay_metaball.c - engines/overlay/overlay_mode_transfer.c - engines/overlay/overlay_motion_path.c - engines/overlay/overlay_outline.c - engines/overlay/overlay_paint.c - engines/overlay/overlay_particle.c - engines/overlay/overlay_sculpt.c + engines/overlay/overlay_edit_mesh.cc + engines/overlay/overlay_edit_text.cc + engines/overlay/overlay_edit_uv.cc + engines/overlay/overlay_engine.cc + engines/overlay/overlay_extra.cc + engines/overlay/overlay_facing.cc + engines/overlay/overlay_fade.cc + engines/overlay/overlay_gpencil.cc + engines/overlay/overlay_grid.cc + engines/overlay/overlay_image.cc + engines/overlay/overlay_lattice.cc + engines/overlay/overlay_metaball.cc + engines/overlay/overlay_mode_transfer.cc + engines/overlay/overlay_motion_path.cc + engines/overlay/overlay_outline.cc + engines/overlay/overlay_paint.cc + engines/overlay/overlay_particle.cc + engines/overlay/overlay_sculpt.cc engines/overlay/overlay_sculpt_curves.cc - engines/overlay/overlay_shader.c - engines/overlay/overlay_volume.c - engines/overlay/overlay_wireframe.c + engines/overlay/overlay_shader.cc + engines/overlay/overlay_volume.cc + engines/overlay/overlay_wireframe.cc DRW_engine.h DRW_select_buffer.h @@ -286,7 +286,7 @@ set(SRC engines/select/select_engine.h engines/select/select_private.h engines/overlay/overlay_engine.h - engines/overlay/overlay_private.h + engines/overlay/overlay_private.hh ) set(LIB diff --git a/source/blender/draw/engines/overlay/overlay_antialiasing.c b/source/blender/draw/engines/overlay/overlay_antialiasing.cc similarity index 98% rename from source/blender/draw/engines/overlay/overlay_antialiasing.c rename to source/blender/draw/engines/overlay/overlay_antialiasing.cc index 5bdc1096edc..2242ad8b609 100644 --- a/source/blender/draw/engines/overlay/overlay_antialiasing.c +++ b/source/blender/draw/engines/overlay/overlay_antialiasing.cc @@ -43,7 +43,7 @@ #include "ED_screen.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_antialiasing_init(OVERLAY_Data *vedata) { @@ -55,7 +55,8 @@ void OVERLAY_antialiasing_init(OVERLAY_Data *vedata) /* Small texture which will have very small impact on render-time. */ if (txl->dummy_depth_tx == NULL) { const float pixel[1] = {1.0f}; - txl->dummy_depth_tx = DRW_texture_create_2d(1, 1, GPU_DEPTH_COMPONENT24, 0, pixel); + txl->dummy_depth_tx = DRW_texture_create_2d( + 1, 1, GPU_DEPTH_COMPONENT24, DRWTextureFlag(0), pixel); } if (!DRW_state_is_fbo()) { @@ -72,7 +73,7 @@ void OVERLAY_antialiasing_init(OVERLAY_Data *vedata) if (pd->antialiasing.enabled) { DRW_texture_ensure_fullscreen_2d(&txl->overlay_color_tx, GPU_SRGB8_A8, DRW_TEX_FILTER); - DRW_texture_ensure_fullscreen_2d(&txl->overlay_line_tx, GPU_RGBA8, 0); + DRW_texture_ensure_fullscreen_2d(&txl->overlay_line_tx, GPU_RGBA8, DRWTextureFlag(0)); color_tex = txl->overlay_color_tx; line_tex = txl->overlay_line_tx; @@ -177,7 +178,7 @@ void OVERLAY_antialiasing_cache_finish(OVERLAY_Data *vedata) const bool do_wireframe = pd->antialiasing.do_depth_copy || pd->antialiasing.do_depth_infront_copy; if (pd->xray_enabled || do_wireframe) { - DRW_texture_ensure_fullscreen_2d(&txl->temp_depth_tx, GPU_DEPTH24_STENCIL8, 0); + DRW_texture_ensure_fullscreen_2d(&txl->temp_depth_tx, GPU_DEPTH24_STENCIL8, DRWTextureFlag(0)); } } diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.cc similarity index 93% rename from source/blender/draw/engines/overlay/overlay_armature.c rename to source/blender/draw/engines/overlay/overlay_armature.cc index df5ee6a18c0..1e10fc7cd20 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.c +++ b/source/blender/draw/engines/overlay/overlay_armature.cc @@ -37,7 +37,7 @@ #include "draw_common.h" #include "draw_manager_text.h" -#include "overlay_private.h" +#include "overlay_private.hh" #include "draw_cache_impl.h" @@ -100,7 +100,7 @@ bool OVERLAY_armature_is_pose_mode(Object *ob, const DRWContextState *draw_ctx) } /* Armature parent is also handled by pose mode engine. */ - if ((active_ob != NULL) && (draw_ctx->object_mode & OB_MODE_ALL_WEIGHT_PAINT)) { + if ((active_ob != nullptr) && (draw_ctx->object_mode & OB_MODE_ALL_WEIGHT_PAINT)) { if (ob == draw_ctx->object_pose) { return true; } @@ -123,7 +123,7 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata) pd->armature.do_pose_xray = (pd->overlay.flag & V3D_OVERLAY_BONE_SELECT) != 0; pd->armature.do_pose_fade_geom = pd->armature.do_pose_xray && ((draw_ctx->object_mode & OB_MODE_WEIGHT_PAINT) == 0) && - draw_ctx->object_pose != NULL; + draw_ctx->object_pose != nullptr; const float wire_alpha = pd->overlay.bone_wire_alpha; const bool use_wire_alpha = (wire_alpha < 1.0f); @@ -139,16 +139,18 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata) DRWShadingGroup *grp; pd->armature_bone_select_act_grp = grp = DRW_shgroup_create(sh, psl->armature_bone_select_ps); - DRW_shgroup_uniform_vec4_copy(grp, "color", (float[4]){0.0f, 0.0f, 0.0f, alpha}); + float4 color = {0.0f, 0.0f, 0.0f, alpha}; + DRW_shgroup_uniform_vec4_copy(grp, "color", color); pd->armature_bone_select_grp = grp = DRW_shgroup_create(sh, psl->armature_bone_select_ps); - DRW_shgroup_uniform_vec4_copy(grp, "color", (float[4]){0.0f, 0.0f, 0.0f, pow(alpha, 4)}); + color = {0.0f, 0.0f, 0.0f, powf(alpha, 4)}; + DRW_shgroup_uniform_vec4_copy(grp, "color", color); } for (int i = 0; i < 2; i++) { struct GPUShader *sh; struct GPUVertFormat *format; - DRWShadingGroup *grp = NULL; + DRWShadingGroup *grp = nullptr; OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); OVERLAY_ArmatureCallBuffers *cb = &pd->armature_call_buffers[i]; @@ -157,7 +159,8 @@ void OVERLAY_armature_cache_init(OVERLAY_Data *vedata) cb->transp.custom_shapes_ghash = BLI_ghash_ptr_new(__func__); DRWPass **p_armature_ps = &psl->armature_ps[i]; - DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : 0; + DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : + DRWState(0); state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_WRITE_DEPTH; DRW_PASS_CREATE(*p_armature_ps, state | pd->clipping_state | infront_state); DRWPass *armature_ps = *p_armature_ps; @@ -612,15 +615,16 @@ static void drw_shgroup_bone_envelope(ArmatureDrawContext *ctx, /* Custom (geometry) */ -extern void drw_batch_cache_validate(Object *custom); -extern void drw_batch_cache_generate_requested_delayed(Object *custom); +extern "C" void drw_batch_cache_validate(Object *custom); +extern "C" void drw_batch_cache_generate_requested_delayed(Object *custom); BLI_INLINE DRWCallBuffer *custom_bone_instance_shgroup(ArmatureDrawContext *ctx, DRWShadingGroup *grp, struct GPUBatch *custom_geom) { - DRWCallBuffer *buf = BLI_ghash_lookup(ctx->custom_shapes_ghash, custom_geom); - if (buf == NULL) { + DRWCallBuffer *buf = static_cast( + BLI_ghash_lookup(ctx->custom_shapes_ghash, custom_geom)); + if (buf == nullptr) { OVERLAY_InstanceFormats *formats = OVERLAY_shader_instance_formats_get(); buf = DRW_shgroup_call_buffer_instance(grp, formats->instance_bone, custom_geom); BLI_ghash_insert(ctx->custom_shapes_ghash, custom_geom, buf); @@ -641,7 +645,7 @@ static void drw_shgroup_bone_custom_solid_mesh(ArmatureDrawContext *ctx, DRW_mesh_batch_cache_validate(custom, mesh); struct GPUBatch *surf = DRW_mesh_batch_cache_get_surface(mesh); - struct GPUBatch *edges = DRW_mesh_batch_cache_get_edge_detection(mesh, NULL); + struct GPUBatch *edges = DRW_mesh_batch_cache_get_edge_detection(mesh, nullptr); struct GPUBatch *ledges = DRW_mesh_batch_cache_get_loose_edges(mesh); BoneInstanceData inst_data; DRWCallBuffer *buf; @@ -710,7 +714,7 @@ static void drw_shgroup_custom_bone_curve(ArmatureDrawContext *ctx, /* This only handles curves without any surface. The other curve types should have been converted * to meshes and rendered in the mesh drawing function. */ - struct GPUBatch *ledges = NULL; + struct GPUBatch *ledges = nullptr; if (custom->type == OB_FONT) { ledges = DRW_cache_text_edge_wire_get(custom); } @@ -744,14 +748,15 @@ static void drw_shgroup_bone_custom_solid(ArmatureDrawContext *ctx, * other data type, but supporting all evaluated geometry components would require a much * larger refactor of this area. */ Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom); - if (mesh != NULL) { + if (mesh != nullptr) { drw_shgroup_bone_custom_solid_mesh( ctx, mesh, bone_mat, bone_color, hint_color, outline_color, custom); return; } if (ELEM(custom->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) { - drw_shgroup_custom_bone_curve(ctx, custom->data, bone_mat, outline_color, custom); + drw_shgroup_custom_bone_curve( + ctx, static_cast(custom->data), bone_mat, outline_color, custom); } } @@ -762,13 +767,14 @@ static void drw_shgroup_bone_custom_wire(ArmatureDrawContext *ctx, { /* See comments in #drw_shgroup_bone_custom_solid. */ Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom); - if (mesh != NULL) { + if (mesh != nullptr) { drw_shgroup_bone_custom_mesh_wire(ctx, mesh, bone_mat, color, custom); return; } if (ELEM(custom->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) { - drw_shgroup_custom_bone_curve(ctx, custom->data, bone_mat, color, custom); + drw_shgroup_custom_bone_curve( + ctx, static_cast(custom->data), bone_mat, color, custom); } } @@ -890,14 +896,14 @@ enum { /* This function sets the color-set for coloring a certain bone */ static void set_pchan_colorset(ArmatureDrawContext *ctx, Object *ob, bPoseChannel *pchan) { - bPose *pose = (ob) ? ob->pose : NULL; - bArmature *arm = (ob) ? ob->data : NULL; - bActionGroup *grp = NULL; + bPose *pose = (ob) ? ob->pose : nullptr; + bArmature *arm = (ob) ? static_cast(ob->data) : nullptr; + bActionGroup *grp = nullptr; short color_index = 0; /* sanity check */ - if (ELEM(NULL, ob, arm, pose, pchan)) { - ctx->bcolor = NULL; + if (ELEM(nullptr, ob, arm, pose, pchan)) { + ctx->bcolor = nullptr; return; } @@ -914,7 +920,7 @@ static void set_pchan_colorset(ArmatureDrawContext *ctx, Object *ob, bPoseChanne } } - /* bcolor is a pointer to the color set to use. If NULL, then the default + /* bcolor is a pointer to the color set to use. If nullptr, then the default * color set (based on the theme colors for 3d-view) is used. */ if (color_index > 0) { @@ -922,11 +928,11 @@ static void set_pchan_colorset(ArmatureDrawContext *ctx, Object *ob, bPoseChanne ctx->bcolor = &btheme->tarm[(color_index - 1)]; } else if (color_index == -1) { - /* use the group's own custom color set (grp is always != NULL here) */ + /* use the group's own custom color set (grp is always != nullptr here) */ ctx->bcolor = &grp->cs; } else { - ctx->bcolor = NULL; + ctx->bcolor = nullptr; } } @@ -1008,7 +1014,7 @@ static bool set_pchan_color(const ArmatureDrawContext *ctx, return true; } case PCHAN_COLOR_CONSTS: { - if ((bcolor == NULL) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) { + if ((bcolor == nullptr) || (bcolor->flag & TH_WIRECOLOR_CONSTCOLS)) { if (constflag & PCHAN_HAS_TARGET) { copy_v4_v4(fcolor, G_draw.block.color_bone_pose_target); } @@ -1192,15 +1198,15 @@ static const float *get_bone_hint_color(const ArmatureDrawContext *ctx, static void pchan_draw_data_init(bPoseChannel *pchan) { - if (pchan->draw_data != NULL) { + if (pchan->draw_data != nullptr) { if (pchan->draw_data->bbone_matrix_len != pchan->bone->segments) { MEM_SAFE_FREE(pchan->draw_data); } } - if (pchan->draw_data == NULL) { - pchan->draw_data = MEM_mallocN( - sizeof(*pchan->draw_data) + sizeof(Mat4) * pchan->bone->segments, __func__); + if (pchan->draw_data == nullptr) { + pchan->draw_data = static_cast( + MEM_mallocN(sizeof(*pchan->draw_data) + sizeof(Mat4) * pchan->bone->segments, __func__)); pchan->draw_data->bbone_matrix_len = pchan->bone->segments; } } @@ -1243,11 +1249,11 @@ static void edbo_compute_bbone_child(bArmature *arm) { EditBone *eBone; - for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { - eBone->bbone_child = NULL; + for (eBone = static_cast(arm->edbo->first); eBone; eBone = eBone->next) { + eBone->bbone_child = nullptr; } - for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { + for (eBone = static_cast(arm->edbo->first); eBone; eBone = eBone->next) { if (eBone->parent && (eBone->flag & BONE_CONNECTED)) { eBone->parent->bbone_child = eBone; } @@ -1274,7 +1280,7 @@ static void ebone_spline_preview(EditBone *ebone, const float result_array[MAX_B prev = ebone->parent; } else { - prev = NULL; + prev = nullptr; } } else { @@ -1398,7 +1404,8 @@ static void draw_bone_update_disp_matrix_bbone(EditBone *eBone, bPoseChannel *pc bbone_segments = eBone->segments; } - size_to_mat4(s, (const float[3]){xwidth, length / bbone_segments, zwidth}); + const float3 size_vec = {xwidth, length / bbone_segments, zwidth}; + size_to_mat4(s, size_vec); /* Compute BBones segment matrices... */ /* Note that we need this even for one-segment bones, because box drawing need specific weirdo @@ -1471,8 +1478,8 @@ static void draw_axes(ArmatureDrawContext *ctx, { float final_col[4]; const float *col = (ctx->const_color) ? ctx->const_color : - (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? G_draw.block.color_text_hi : - G_draw.block.color_text; + (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? &G_draw.block.color_text_hi.x : + &G_draw.block.color_text.x; copy_v4_v4(final_col, col); /* Mix with axes color. */ final_col[3] = (ctx->const_color) ? 1.0 : (BONE_FLAG(eBone, pchan) & BONE_SELECTED) ? 0.1 : 0.65; @@ -1483,7 +1490,8 @@ static void draw_axes(ArmatureDrawContext *ctx, float axis_mat[4][4]; float length = pchan->bone->length; copy_m4_m4(axis_mat, pchan->custom_tx ? pchan->custom_tx->pose_mat : pchan->pose_mat); - rescale_m4(axis_mat, (float[3]){length, length, length}); + const float3 length_vec = {length, length, length}; + rescale_m4(axis_mat, length_vec); translate_m4(axis_mat, 0.0, arm->axes_position - 1.0, 0.0); drw_shgroup_bone_axes(ctx, axis_mat, final_col); @@ -1509,8 +1517,8 @@ static void draw_points(ArmatureDrawContext *ctx, copy_v4_v4(col_solid_root, G_draw.block.color_bone_solid); copy_v4_v4(col_solid_tail, G_draw.block.color_bone_solid); - copy_v4_v4(col_wire_root, (ctx->const_color) ? ctx->const_color : G_draw.block.color_vertex); - copy_v4_v4(col_wire_tail, (ctx->const_color) ? ctx->const_color : G_draw.block.color_vertex); + copy_v4_v4(col_wire_root, (ctx->const_color) ? ctx->const_color : &G_draw.block.color_vertex.x); + copy_v4_v4(col_wire_tail, (ctx->const_color) ? ctx->const_color : &G_draw.block.color_vertex.x); const bool is_envelope_draw = (arm->drawtype == ARM_ENVELOPE); const float envelope_ignore = -1.0f; @@ -1704,7 +1712,7 @@ static void draw_bone_line(ArmatureDrawContext *ctx, const float *col_head = no_display; const float *col_tail = col_bone; - if (ctx->const_color != NULL) { + if (ctx->const_color != nullptr) { col_wire = no_display; /* actually shrink the display. */ col_bone = col_head = col_tail = ctx->const_color; } @@ -1724,7 +1732,7 @@ static void draw_bone_line(ArmatureDrawContext *ctx, (pchan->bone->parent && (boneflag & BONE_CONNECTED)))) { if (eBone) { - col_head = (eBone->flag & BONE_ROOTSEL) ? G_draw.block.color_vertex_select : col_bone; + col_head = (eBone->flag & BONE_ROOTSEL) ? &G_draw.block.color_vertex_select.x : col_bone; } else { col_head = col_bone; @@ -1773,7 +1781,7 @@ static void draw_bone_wire(ArmatureDrawContext *ctx, if (pchan) { Mat4 *bbones_mat = (Mat4 *)pchan->draw_data->bbone_matrix; - BLI_assert(bbones_mat != NULL); + BLI_assert(bbones_mat != nullptr); for (int i = pchan->bone->segments; i--; bbones_mat++) { drw_shgroup_bone_wire(ctx, bbones_mat->mat, col_wire); @@ -1813,7 +1821,7 @@ static void draw_bone_box(ArmatureDrawContext *ctx, if (pchan) { Mat4 *bbones_mat = (Mat4 *)pchan->draw_data->bbone_matrix; - BLI_assert(bbones_mat != NULL); + BLI_assert(bbones_mat != nullptr); for (int i = pchan->bone->segments; i--; bbones_mat++) { drw_shgroup_bone_box(ctx, bbones_mat->mat, col_solid, col_hint, col_wire); @@ -1874,7 +1882,7 @@ static void draw_bone_degrees_of_freedom(ArmatureDrawContext *ctx, bPoseChannel float xminmax[2], zminmax[2]; float color[4]; - if (ctx->dof_sphere == NULL) { + if (ctx->dof_sphere == nullptr) { return; } @@ -1938,9 +1946,9 @@ static void pchan_draw_ik_lines(ArmatureDrawContext *ctx, { bConstraint *con; bPoseChannel *parchan; - float *line_start = NULL, *line_end = NULL; + float *line_start = nullptr, *line_end = nullptr; - for (con = pchan->constraints.first; con; con = con->next) { + for (con = static_cast(pchan->constraints.first); con; con = con->next) { if (con->enforce == 0.0f) { continue; } @@ -2163,7 +2171,7 @@ static bool pchan_culling_test_envelope(const DRWView *view, const Object *ob, const bPoseChannel *pchan) { - const bArmature *arm = ob->data; + const bArmature *arm = static_cast(ob->data); BLI_assert(arm->drawtype == ARM_ENVELOPE); UNUSED_VARS_NDEBUG(arm); BoundSphere bsphere; @@ -2177,7 +2185,7 @@ static bool pchan_culling_test_bbone(const DRWView *view, const Object *ob, const bPoseChannel *pchan) { - const bArmature *arm = ob->data; + const bArmature *arm = static_cast(ob->data); BLI_assert(arm->drawtype == ARM_B_BONE); UNUSED_VARS_NDEBUG(arm); const float ob_scale = mat4_to_size_max_axis(ob->obmat); @@ -2224,11 +2232,12 @@ static void draw_armature_edit(ArmatureDrawContext *ctx) * however the active bone isn't updated. Long term solution is an 'EditArmature' struct. * for now we can draw from the original armature. See: T66773. */ // bArmature *arm = ob->data; - bArmature *arm = ob_orig->data; + bArmature *arm = static_cast(ob_orig->data); edbo_compute_bbone_child(arm); - for (eBone = arm->edbo->first, index = ob_orig->runtime.select_id; eBone; + for (eBone = static_cast(arm->edbo->first), index = ob_orig->runtime.select_id; + eBone; eBone = eBone->next, index += 0x10000) { if (eBone->layer & arm->layer) { if ((eBone->flag & BONE_HIDDEN_A) == 0) { @@ -2249,37 +2258,37 @@ static void draw_armature_edit(ArmatureDrawContext *ctx) boneflag &= ~BONE_DRAW_LOCKED_WEIGHT; if (!is_select) { - draw_bone_relations(ctx, eBone, NULL, arm, boneflag, constflag); + draw_bone_relations(ctx, eBone, nullptr, arm, boneflag, constflag); } if (arm->drawtype == ARM_ENVELOPE) { - draw_bone_update_disp_matrix_default(eBone, NULL); - draw_bone_envelope(ctx, eBone, NULL, arm, boneflag, constflag, select_id); + draw_bone_update_disp_matrix_default(eBone, nullptr); + draw_bone_envelope(ctx, eBone, nullptr, arm, boneflag, constflag, select_id); } else if (arm->drawtype == ARM_LINE) { - draw_bone_update_disp_matrix_default(eBone, NULL); - draw_bone_line(ctx, eBone, NULL, arm, boneflag, constflag, select_id); + draw_bone_update_disp_matrix_default(eBone, nullptr); + draw_bone_line(ctx, eBone, nullptr, arm, boneflag, constflag, select_id); } else if (arm->drawtype == ARM_WIRE) { - draw_bone_update_disp_matrix_bbone(eBone, NULL); - draw_bone_wire(ctx, eBone, NULL, arm, boneflag, constflag, select_id); + draw_bone_update_disp_matrix_bbone(eBone, nullptr); + draw_bone_wire(ctx, eBone, nullptr, arm, boneflag, constflag, select_id); } else if (arm->drawtype == ARM_B_BONE) { - draw_bone_update_disp_matrix_bbone(eBone, NULL); - draw_bone_box(ctx, eBone, NULL, arm, boneflag, constflag, select_id); + draw_bone_update_disp_matrix_bbone(eBone, nullptr); + draw_bone_box(ctx, eBone, nullptr, arm, boneflag, constflag, select_id); } else { - draw_bone_update_disp_matrix_default(eBone, NULL); - draw_bone_octahedral(ctx, eBone, NULL, arm, boneflag, constflag, select_id); + draw_bone_update_disp_matrix_default(eBone, nullptr); + draw_bone_octahedral(ctx, eBone, nullptr, arm, boneflag, constflag, select_id); } if (!is_select) { if (show_text && (arm->flag & ARM_DRAWNAMES)) { - draw_bone_name(ctx, eBone, NULL, arm, boneflag); + draw_bone_name(ctx, eBone, nullptr, arm, boneflag); } if (arm->flag & ARM_DRAWAXES) { - draw_axes(ctx, eBone, NULL, arm); + draw_axes(ctx, eBone, nullptr, arm); } } } @@ -2292,13 +2301,13 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) Object *ob = ctx->ob; const DRWContextState *draw_ctx = DRW_context_state_get(); const Scene *scene = draw_ctx->scene; - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); bPoseChannel *pchan; int index = -1; const bool show_text = DRW_state_show_text(); bool draw_locked_weights = false; - /* We can't safely draw non-updated pose, might contain NULL bone pointers... */ + /* We can't safely draw non-updated pose, might contain nullptr bone pointers... */ if (ob->pose->flag & POSE_RECALC) { return; } @@ -2323,7 +2332,7 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) /* Allow selection when in weight-paint mode * (selection code ensures this won't become active). */ ((draw_ctx->object_mode & OB_MODE_ALL_WEIGHT_PAINT) && - (draw_ctx->object_pose != NULL))))) && + (draw_ctx->object_pose != nullptr))))) && DRW_state_is_select(); if (is_pose_select) { @@ -2334,10 +2343,11 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) /* In weight paint mode retrieve the vertex group lock status. */ if ((draw_ctx->object_mode & OB_MODE_ALL_WEIGHT_PAINT) && (draw_ctx->object_pose == ob) && - (draw_ctx->obact != NULL)) { + (draw_ctx->obact != nullptr)) { draw_locked_weights = true; - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; + pchan = pchan->next) { pchan->bone->flag &= ~BONE_DRAW_LOCKED_WEIGHT; } @@ -2355,9 +2365,10 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) } } - const DRWView *view = is_pose_select ? DRW_view_default_get() : NULL; + const DRWView *view = is_pose_select ? DRW_view_default_get() : nullptr; - for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, index += 0x10000) { + for (pchan = static_cast(ob->pose->chanbase.first); pchan; + pchan = pchan->next, index += 0x10000) { Bone *bone = pchan->bone; const bool bone_visible = (bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG)) == 0; @@ -2392,43 +2403,43 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) } if (!is_pose_select) { - draw_bone_relations(ctx, NULL, pchan, arm, boneflag, constflag); + draw_bone_relations(ctx, nullptr, pchan, arm, boneflag, constflag); } if ((pchan->custom) && !(arm->flag & ARM_NO_CUSTOM)) { draw_bone_update_disp_matrix_custom(pchan); if (!is_pose_select || pchan_culling_test_custom(view, ob, pchan)) { - draw_bone_custom_shape(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + draw_bone_custom_shape(ctx, nullptr, pchan, arm, boneflag, constflag, select_id); } } else if (arm->drawtype == ARM_ENVELOPE) { - draw_bone_update_disp_matrix_default(NULL, pchan); + draw_bone_update_disp_matrix_default(nullptr, pchan); if (!is_pose_select || pchan_culling_test_envelope(view, ob, pchan)) { - draw_bone_envelope(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + draw_bone_envelope(ctx, nullptr, pchan, arm, boneflag, constflag, select_id); } } else if (arm->drawtype == ARM_LINE) { - draw_bone_update_disp_matrix_default(NULL, pchan); + draw_bone_update_disp_matrix_default(nullptr, pchan); if (!is_pose_select || pchan_culling_test_line(view, ob, pchan)) { - draw_bone_line(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + draw_bone_line(ctx, nullptr, pchan, arm, boneflag, constflag, select_id); } } else if (arm->drawtype == ARM_WIRE) { - draw_bone_update_disp_matrix_bbone(NULL, pchan); + draw_bone_update_disp_matrix_bbone(nullptr, pchan); if (!is_pose_select || pchan_culling_test_wire(view, ob, pchan)) { - draw_bone_wire(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + draw_bone_wire(ctx, nullptr, pchan, arm, boneflag, constflag, select_id); } } else if (arm->drawtype == ARM_B_BONE) { - draw_bone_update_disp_matrix_bbone(NULL, pchan); + draw_bone_update_disp_matrix_bbone(nullptr, pchan); if (!is_pose_select || pchan_culling_test_bbone(view, ob, pchan)) { - draw_bone_box(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + draw_bone_box(ctx, nullptr, pchan, arm, boneflag, constflag, select_id); } } else { - draw_bone_update_disp_matrix_default(NULL, pchan); + draw_bone_update_disp_matrix_default(nullptr, pchan); if (!is_pose_select || pchan_culling_test_octohedral(view, ob, pchan)) { - draw_bone_octahedral(ctx, NULL, pchan, arm, boneflag, constflag, select_id); + draw_bone_octahedral(ctx, nullptr, pchan, arm, boneflag, constflag, select_id); } } @@ -2439,11 +2450,11 @@ static void draw_armature_pose(ArmatureDrawContext *ctx) } if (show_text && (arm->flag & ARM_DRAWNAMES)) { - draw_bone_name(ctx, NULL, pchan, arm, boneflag); + draw_bone_name(ctx, nullptr, pchan, arm, boneflag); } if (arm->flag & ARM_DRAWAXES) { - draw_axes(ctx, NULL, pchan, arm); + draw_axes(ctx, nullptr, pchan, arm); } } } @@ -2467,7 +2478,7 @@ static void armature_context_setup(ArmatureDrawContext *ctx, const bool draw_as_wire = (ob->dt < OB_SOLID); const bool is_filled = (!pd->armature.transparent && !draw_as_wire) || !is_object_mode; const bool is_transparent = pd->armature.transparent || (draw_as_wire && !is_object_mode); - bArmature *arm = ob->data; + bArmature *arm = static_cast(ob->data); OVERLAY_ArmatureCallBuffers *cbo = &pd->armature_call_buffers[is_xray]; OVERLAY_ArmatureCallBuffersInner *cb = is_transparent ? &cbo->transp : &cbo->solid; @@ -2476,8 +2487,8 @@ static void armature_context_setup(ArmatureDrawContext *ctx, switch (arm->drawtype) { case ARM_ENVELOPE: ctx->envelope_outline = cb->envelope_outline; - ctx->envelope_solid = (is_filled) ? cb->envelope_fill : NULL; - ctx->envelope_distance = (do_envelope_dist) ? cb->envelope_distance : NULL; + ctx->envelope_solid = (is_filled) ? cb->envelope_fill : nullptr; + ctx->envelope_distance = (do_envelope_dist) ? cb->envelope_distance : nullptr; break; case ARM_LINE: ctx->stick = cb->stick; @@ -2487,20 +2498,20 @@ static void armature_context_setup(ArmatureDrawContext *ctx, break; case ARM_B_BONE: ctx->outline = cb->box_outline; - ctx->solid = (is_filled) ? cb->box_fill : NULL; + ctx->solid = (is_filled) ? cb->box_fill : nullptr; break; case ARM_OCTA: ctx->outline = cb->octa_outline; - ctx->solid = (is_filled) ? cb->octa_fill : NULL; + ctx->solid = (is_filled) ? cb->octa_fill : nullptr; break; } ctx->ob = ob; ctx->extras = &pd->extra_call_buffers[is_xray]; ctx->dof_lines = cb->dof_lines; ctx->dof_sphere = cb->dof_sphere; - ctx->point_solid = (is_filled) ? cb->point_fill : NULL; + ctx->point_solid = (is_filled) ? cb->point_fill : nullptr; ctx->point_outline = cb->point_outline; - ctx->custom_solid = (is_filled) ? cb->custom_fill : NULL; + ctx->custom_solid = (is_filled) ? cb->custom_fill : nullptr; ctx->custom_outline = cb->custom_outline; ctx->custom_wire = cb->custom_wire; ctx->custom_shapes_ghash = cb->custom_shapes_ghash; @@ -2518,7 +2529,7 @@ void OVERLAY_edit_armature_cache_populate(OVERLAY_Data *vedata, Object *ob) { OVERLAY_PrivateData *pd = vedata->stl->pd; ArmatureDrawContext arm_ctx; - armature_context_setup(&arm_ctx, pd, ob, true, true, false, NULL); + armature_context_setup(&arm_ctx, pd, ob, true, true, false, nullptr); draw_armature_edit(&arm_ctx); } @@ -2526,7 +2537,7 @@ void OVERLAY_pose_armature_cache_populate(OVERLAY_Data *vedata, Object *ob) { OVERLAY_PrivateData *pd = vedata->stl->pd; ArmatureDrawContext arm_ctx; - armature_context_setup(&arm_ctx, pd, ob, true, false, true, NULL); + armature_context_setup(&arm_ctx, pd, ob, true, false, true, nullptr); draw_armature_pose(&arm_ctx); } @@ -2586,8 +2597,8 @@ void OVERLAY_armature_cache_finish(OVERLAY_Data *vedata) for (int i = 0; i < 2; i++) { if (pd->armature_call_buffers[i].solid.custom_shapes_ghash) { /* TODO(fclem): Do not free it for each frame but reuse it. Avoiding alloc cost. */ - BLI_ghash_free(pd->armature_call_buffers[i].solid.custom_shapes_ghash, NULL, NULL); - BLI_ghash_free(pd->armature_call_buffers[i].transp.custom_shapes_ghash, NULL, NULL); + BLI_ghash_free(pd->armature_call_buffers[i].solid.custom_shapes_ghash, nullptr, nullptr); + BLI_ghash_free(pd->armature_call_buffers[i].transp.custom_shapes_ghash, nullptr, nullptr); } } } @@ -2604,7 +2615,7 @@ void OVERLAY_armature_in_front_draw(OVERLAY_Data *vedata) { OVERLAY_PassList *psl = vedata->psl; - if (psl->armature_bone_select_ps == NULL || DRW_state_is_select()) { + if (psl->armature_bone_select_ps == nullptr || DRW_state_is_select()) { DRW_draw_pass(psl->armature_transp_ps[1]); DRW_draw_pass(psl->armature_ps[1]); } @@ -2615,7 +2626,7 @@ void OVERLAY_pose_draw(OVERLAY_Data *vedata) OVERLAY_PassList *psl = vedata->psl; OVERLAY_FramebufferList *fbl = vedata->fbl; - if (psl->armature_bone_select_ps != NULL) { + if (psl->armature_bone_select_ps != nullptr) { if (DRW_state_is_fbo()) { GPU_framebuffer_bind(fbl->overlay_default_fb); } diff --git a/source/blender/draw/engines/overlay/overlay_background.c b/source/blender/draw/engines/overlay/overlay_background.cc similarity index 94% rename from source/blender/draw/engines/overlay/overlay_background.c rename to source/blender/draw/engines/overlay/overlay_background.cc index 32bcd04e05b..e8bae74c70a 100644 --- a/source/blender/draw/engines/overlay/overlay_background.c +++ b/source/blender/draw/engines/overlay/overlay_background.cc @@ -10,7 +10,7 @@ #include "UI_resources.h" #include "draw_manager_text.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_background_cache_init(OVERLAY_Data *vedata) { @@ -20,7 +20,7 @@ void OVERLAY_background_cache_init(OVERLAY_Data *vedata) const DRWContextState *draw_ctx = DRW_context_state_get(); const Scene *scene = draw_ctx->scene; const RegionView3D *rv3d = draw_ctx->rv3d; - const BoundBox *bb = rv3d ? rv3d->clipbb : NULL; + const BoundBox *bb = rv3d ? rv3d->clipbb : nullptr; const View3D *v3d = draw_ctx->v3d; bool draw_clipping_bounds = (pd->clipping_state != 0); @@ -80,7 +80,7 @@ void OVERLAY_background_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth); DRW_shgroup_uniform_vec4_copy(grp, "colorOverride", color_override); DRW_shgroup_uniform_int_copy(grp, "bgType", background_type); - DRW_shgroup_call_procedural_triangles(grp, NULL, 1); + DRW_shgroup_call_procedural_triangles(grp, nullptr, 1); } if (draw_clipping_bounds) { @@ -93,10 +93,10 @@ void OVERLAY_background_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec3(grp, "boundbox", &bb->vec[0][0], 8); struct GPUBatch *cube = DRW_cache_cube_get(); - DRW_shgroup_call(grp, cube, NULL); + DRW_shgroup_call(grp, cube, nullptr); } else { - psl->clipping_frustum_ps = NULL; + psl->clipping_frustum_ps = nullptr; } } diff --git a/source/blender/draw/engines/overlay/overlay_edit_curve.c b/source/blender/draw/engines/overlay/overlay_edit_curve.cc similarity index 98% rename from source/blender/draw/engines/overlay/overlay_edit_curve.c rename to source/blender/draw/engines/overlay/overlay_edit_curve.cc index 09e3c3410c3..b84eb9b3a43 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_curve.c +++ b/source/blender/draw/engines/overlay/overlay_edit_curve.cc @@ -9,7 +9,7 @@ #include "DNA_curve_types.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_edit_curve_cache_init(OVERLAY_Data *vedata) { @@ -65,7 +65,7 @@ void OVERLAY_edit_curve_cache_populate(OVERLAY_Data *vedata, Object *ob) bool draw_normals = (pd->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_NORMALS) != 0; bool do_xray = (ob->dtx & OB_DRAW_IN_FRONT) != 0; - Curve *cu = ob->data; + Curve *cu = static_cast(ob->data); struct GPUBatch *geom; geom = DRW_cache_curve_edge_wire_get(ob); diff --git a/source/blender/draw/engines/overlay/overlay_edit_curves.cc b/source/blender/draw/engines/overlay/overlay_edit_curves.cc index 02e40ea0304..dab44c655a5 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_edit_curves.cc @@ -11,7 +11,7 @@ #include "draw_cache_impl.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_edit_curves_init(OVERLAY_Data *vedata) { diff --git a/source/blender/draw/engines/overlay/overlay_edit_mesh.c b/source/blender/draw/engines/overlay/overlay_edit_mesh.cc similarity index 94% rename from source/blender/draw/engines/overlay/overlay_edit_mesh.c rename to source/blender/draw/engines/overlay/overlay_edit_mesh.cc index 4d65cbc04ff..4509fd53ed8 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_mesh.c +++ b/source/blender/draw/engines/overlay/overlay_edit_mesh.cc @@ -18,7 +18,7 @@ #include "draw_cache_impl.h" #include "draw_manager_text.h" -#include "overlay_private.h" +#include "overlay_private.hh" #define OVERLAY_EDIT_TEXT \ (V3D_OVERLAY_EDIT_EDGE_LEN | V3D_OVERLAY_EDIT_FACE_AREA | V3D_OVERLAY_EDIT_FACE_ANG | \ @@ -45,9 +45,9 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata) OVERLAY_PassList *psl = vedata->psl; OVERLAY_PrivateData *pd = vedata->stl->pd; OVERLAY_ShadingData *shdata = &pd->shdata; - DRWShadingGroup *grp = NULL; - GPUShader *sh = NULL; - DRWState state = 0; + DRWShadingGroup *grp = nullptr; + GPUShader *sh = nullptr; + DRWState state = DRWState(0); DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); @@ -109,7 +109,7 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata) { /* Normals */ state = DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL | - (pd->edit_mesh.do_zbufclip ? DRW_STATE_BLEND_ALPHA : 0); + (pd->edit_mesh.do_zbufclip ? DRW_STATE_BLEND_ALPHA : DRWState(0)); DRW_PASS_CREATE(psl->edit_mesh_normals_ps, state | pd->clipping_state); sh = OVERLAY_shader_edit_mesh_normal(); @@ -204,7 +204,7 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata) DRW_shgroup_state_enable(grp, DRW_STATE_WRITE_DEPTH); } else { - pd->edit_mesh_facedots_grp[i] = NULL; + pd->edit_mesh_facedots_grp[i] = nullptr; } } } @@ -234,24 +234,24 @@ static void overlay_edit_mesh_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob pd->edit_mesh_faces_grp[in_front]; skin_roots_shgrp = pd->edit_mesh_skin_roots_grp[in_front]; - geom_edges = DRW_mesh_batch_cache_get_edit_edges(ob->data); - geom_tris = DRW_mesh_batch_cache_get_edit_triangles(ob->data); + geom_edges = DRW_mesh_batch_cache_get_edit_edges(me); + geom_tris = DRW_mesh_batch_cache_get_edit_triangles(me); DRW_shgroup_call_no_cull(edge_shgrp, geom_edges, ob); DRW_shgroup_call_no_cull(face_shgrp, geom_tris, ob); if (pd->edit_mesh.select_vert) { - geom_verts = DRW_mesh_batch_cache_get_edit_vertices(ob->data); + geom_verts = DRW_mesh_batch_cache_get_edit_vertices(me); DRW_shgroup_call_no_cull(vert_shgrp, geom_verts, ob); if (has_skin_roots) { circle = DRW_cache_circle_get(); - skin_roots = DRW_mesh_batch_cache_get_edit_skin_roots(ob->data); + skin_roots = DRW_mesh_batch_cache_get_edit_skin_roots(me); DRW_shgroup_call_instances_with_attrs(skin_roots_shgrp, ob, circle, skin_roots); } } if (fdot_shgrp) { - geom_fcenter = DRW_mesh_batch_cache_get_edit_facedots(ob->data); + geom_fcenter = DRW_mesh_batch_cache_get_edit_facedots(me); DRW_shgroup_call_no_cull(fdot_shgrp, geom_fcenter, ob); } } @@ -259,7 +259,7 @@ static void overlay_edit_mesh_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob) { OVERLAY_PrivateData *pd = vedata->stl->pd; - struct GPUBatch *geom = NULL; + struct GPUBatch *geom = nullptr; bool draw_as_solid = (ob->dt > OB_WIRE); bool do_in_front = (ob->dtx & OB_DRAW_IN_FRONT) != 0; @@ -283,16 +283,17 @@ void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob) if (vnormals_do || lnormals_do || fnormals_do) { struct GPUBatch *normal_geom = DRW_cache_normal_arrow_get(); + Mesh *me = static_cast(ob->data); if (vnormals_do) { - geom = DRW_mesh_batch_cache_get_edit_vnors(ob->data); + geom = DRW_mesh_batch_cache_get_edit_vnors(me); DRW_shgroup_call_instances_with_attrs(pd->edit_mesh_normals_grp, ob, normal_geom, geom); } if (lnormals_do) { - geom = DRW_mesh_batch_cache_get_edit_lnors(ob->data); + geom = DRW_mesh_batch_cache_get_edit_lnors(me); DRW_shgroup_call_instances_with_attrs(pd->edit_mesh_normals_grp, ob, normal_geom, geom); } if (fnormals_do) { - geom = DRW_mesh_batch_cache_get_edit_facedots(ob->data); + geom = DRW_mesh_batch_cache_get_edit_facedots(me); DRW_shgroup_call_instances_with_attrs(pd->edit_mesh_normals_grp, ob, normal_geom, geom); } } @@ -351,7 +352,7 @@ void OVERLAY_edit_mesh_draw(OVERLAY_Data *vedata) DRW_view_set_active(pd->view_edit_faces_cage); DRW_draw_pass(psl->edit_mesh_faces_cage_ps[NOT_IN_FRONT]); - DRW_view_set_active(NULL); + DRW_view_set_active(nullptr); GPU_framebuffer_bind(fbl->overlay_in_front_fb); GPU_framebuffer_clear_depth(fbl->overlay_in_front_fb, 1.0f); @@ -372,7 +373,7 @@ void OVERLAY_edit_mesh_draw(OVERLAY_Data *vedata) } if (!DRW_pass_is_empty(psl->edit_mesh_depth_ps[IN_FRONT])) { - DRW_view_set_active(NULL); + DRW_view_set_active(nullptr); DRW_draw_pass(psl->edit_mesh_depth_ps[IN_FRONT]); } diff --git a/source/blender/draw/engines/overlay/overlay_edit_text.c b/source/blender/draw/engines/overlay/overlay_edit_text.cc similarity index 97% rename from source/blender/draw/engines/overlay/overlay_edit_text.c rename to source/blender/draw/engines/overlay/overlay_edit_text.cc index bd8720042f1..f541619ccdd 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_text.c +++ b/source/blender/draw/engines/overlay/overlay_edit_text.cc @@ -13,7 +13,7 @@ #include "DNA_curve_types.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_edit_text_cache_init(OVERLAY_Data *vedata) { @@ -83,7 +83,7 @@ static void v2_quad_corners_to_mat4(const float corners[4][2], float r_mat[4][4] static void edit_text_cache_populate_select(OVERLAY_Data *vedata, Object *ob) { OVERLAY_PrivateData *pd = vedata->stl->pd; - const Curve *cu = ob->data; + const Curve *cu = static_cast(ob->data); EditFont *ef = cu->editfont; float final_mat[4][4], box[4][2]; struct GPUBatch *geom = DRW_cache_quad_get(); @@ -128,7 +128,7 @@ static void edit_text_cache_populate_select(OVERLAY_Data *vedata, Object *ob) static void edit_text_cache_populate_cursor(OVERLAY_Data *vedata, Object *ob) { OVERLAY_PrivateData *pd = vedata->stl->pd; - const Curve *cu = ob->data; + const Curve *cu = static_cast(ob->data); EditFont *edit_font = cu->editfont; float(*cursor)[2] = edit_font->textcurs; float mat[4][4]; @@ -143,7 +143,7 @@ static void edit_text_cache_populate_cursor(OVERLAY_Data *vedata, Object *ob) static void edit_text_cache_populate_boxes(OVERLAY_Data *vedata, Object *ob) { OVERLAY_ExtraCallBuffers *cb = OVERLAY_extra_call_buffer_get(vedata, ob); - const Curve *cu = ob->data; + const Curve *cu = static_cast(ob->data); for (int i = 0; i < cu->totbox; i++) { TextBox *tb = &cu->tb[i]; diff --git a/source/blender/draw/engines/overlay/overlay_edit_uv.c b/source/blender/draw/engines/overlay/overlay_edit_uv.cc similarity index 87% rename from source/blender/draw/engines/overlay/overlay_edit_uv.c rename to source/blender/draw/engines/overlay/overlay_edit_uv.cc index d2737d73333..c173201b271 100644 --- a/source/blender/draw/engines/overlay/overlay_edit_uv.c +++ b/source/blender/draw/engines/overlay/overlay_edit_uv.cc @@ -31,7 +31,7 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "overlay_private.h" +#include "overlay_private.hh" /* Forward declarations. */ static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob); @@ -70,7 +70,7 @@ static GPUTexture *edit_uv_mask_texture( { const int height = (float)height_ * (aspy / aspx); MaskRasterHandle *handle; - float *buffer = MEM_mallocN(sizeof(float) * height * width, __func__); + float *buffer = static_cast(MEM_mallocN(sizeof(float) * height * width, __func__)); /* Initialize rasterization handle. */ handle = BKE_maskrasterize_handle_new(); @@ -102,10 +102,12 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) Image *image = sima->image; /* By design no image is an image type. This so editor shows UV's by default. */ - const bool is_image_type = - (image == NULL) || ELEM(image->type, IMA_TYPE_IMAGE, IMA_TYPE_MULTILAYER, IMA_TYPE_UV_TEST); + const bool is_image_type = (image == nullptr) || ELEM(image->type, + IMA_TYPE_IMAGE, + IMA_TYPE_MULTILAYER, + IMA_TYPE_UV_TEST); const bool is_uv_editor = sima->mode == SI_MODE_UV; - const bool has_edit_object = (draw_ctx->object_edit) != NULL; + const bool has_edit_object = (draw_ctx->object_edit) != nullptr; const bool is_paint_mode = sima->mode == SI_MODE_PAINT; const bool is_view_mode = sima->mode == SI_MODE_VIEW; const bool is_mask_mode = sima->mode == SI_MODE_MASK; @@ -141,12 +143,13 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) ((draw_ctx->object_mode & (OB_MODE_TEXTURE_PAINT)) != 0)) || (do_uv_overlay && (show_modified_uvs))); - pd->edit_uv.do_mask_overlay = show_overlays && is_mask_mode && (sima->mask_info.mask != NULL) && + pd->edit_uv.do_mask_overlay = show_overlays && is_mask_mode && + (sima->mask_info.mask != nullptr) && ((sima->mask_info.draw_flag & MASK_DRAWFLAG_OVERLAY) != 0); - pd->edit_uv.mask_overlay_mode = sima->mask_info.overlay_mode; + pd->edit_uv.mask_overlay_mode = eMaskOverlayMode(sima->mask_info.overlay_mode); pd->edit_uv.mask = sima->mask_info.mask ? (Mask *)DEG_get_evaluated_id( draw_ctx->depsgraph, &sima->mask_info.mask->id) : - NULL; + nullptr; pd->edit_uv.do_uv_stretching_overlay = show_overlays && do_uvstretching_overlay; pd->edit_uv.uv_opacity = sima->uv_opacity; @@ -157,7 +160,7 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata) pd->edit_uv.do_smooth_wire = ((U.gpu_flag & USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE) != 0); pd->edit_uv.do_stencil_overlay = show_overlays && do_stencil_overlay; - pd->edit_uv.draw_type = sima->dt_uvstretch; + pd->edit_uv.draw_type = eSpaceImage_UVDT_Stretch(sima->dt_uvstretch); BLI_listbase_clear(&pd->edit_uv.totals); pd->edit_uv.total_area_ratio = 0.0f; @@ -299,7 +302,8 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->edit_uv_tiled_image_borders_ps); DRW_shgroup_uniform_vec4_copy(grp, "color", theme_color); - DRW_shgroup_uniform_vec3_copy(grp, "offset", (float[3]){0.0f, 0.0f, 0.0f}); + const float3 offset = {0.0f, 0.0f, 0.0f}; + DRW_shgroup_uniform_vec3_copy(grp, "offset", offset); LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) { const int tile_x = ((tile->tile_number - 1001) % 10); @@ -311,7 +315,8 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) /* Only mark active border when overlays are enabled. */ if (pd->edit_uv.do_tiled_image_overlay) { /* Active tile border */ - ImageTile *active_tile = BLI_findlink(&image->tiles, image->active_tile_index); + ImageTile *active_tile = static_cast( + BLI_findlink(&image->tiles, image->active_tile_index)); if (active_tile) { obmat[3][0] = (float)((active_tile->tile_number - 1001) % 10); obmat[3][1] = (float)((active_tile->tile_number - 1001) / 10); @@ -330,8 +335,9 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) char text[16]; LISTBASE_FOREACH (ImageTile *, tile, &image->tiles) { BLI_snprintf(text, 5, "%d", tile->tile_number); - float tile_location[3] = { - ((tile->tile_number - 1001) % 10), ((tile->tile_number - 1001) / 10), 0.0f}; + float tile_location[3] = {static_cast((tile->tile_number - 1001) % 10), + static_cast((tile->tile_number - 1001) / 10), + 0.0f}; DRW_text_cache_add( dt, tile_location, text, strlen(text), 10, 10, DRW_TEXT_CACHE_GLOBALSPACE, color); } @@ -340,11 +346,12 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) if (pd->edit_uv.do_stencil_overlay) { const Brush *brush = BKE_paint_brush(&ts->imapaint.paint); Image *stencil_image = brush->clone.image; - ImBuf *stencil_ibuf = BKE_image_acquire_ibuf(stencil_image, NULL, &pd->edit_uv.stencil_lock); + ImBuf *stencil_ibuf = BKE_image_acquire_ibuf( + stencil_image, nullptr, &pd->edit_uv.stencil_lock); - if (stencil_ibuf == NULL) { - pd->edit_uv.stencil_ibuf = NULL; - pd->edit_uv.stencil_image = NULL; + if (stencil_ibuf == nullptr) { + pd->edit_uv.stencil_ibuf = nullptr; + pd->edit_uv.stencil_image = nullptr; } else { DRW_PASS_CREATE(psl->edit_uv_stencil_ps, @@ -355,16 +362,18 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->edit_uv_stencil_ps); pd->edit_uv.stencil_ibuf = stencil_ibuf; pd->edit_uv.stencil_image = stencil_image; - GPUTexture *stencil_texture = BKE_image_get_gpu_texture(stencil_image, NULL, stencil_ibuf); + GPUTexture *stencil_texture = BKE_image_get_gpu_texture( + stencil_image, nullptr, stencil_ibuf); DRW_shgroup_uniform_texture(grp, "imgTexture", stencil_texture); DRW_shgroup_uniform_bool_copy(grp, "imgPremultiplied", true); DRW_shgroup_uniform_bool_copy(grp, "imgAlphaBlend", true); - DRW_shgroup_uniform_vec4_copy( - grp, "color", (float[4]){1.0f, 1.0f, 1.0f, brush->clone.alpha}); + const float4 color = {1.0f, 1.0f, 1.0f, brush->clone.alpha}; + DRW_shgroup_uniform_vec4_copy(grp, "color", color); float size_image[2]; - BKE_image_get_size_fl(image, NULL, size_image); - float size_stencil_image[2] = {stencil_ibuf->x, stencil_ibuf->y}; + BKE_image_get_size_fl(image, nullptr, size_image); + float size_stencil_image[2] = {static_cast(stencil_ibuf->x), + static_cast(stencil_ibuf->y)}; float obmat[4][4]; unit_m4(obmat); @@ -377,8 +386,8 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) } } else { - pd->edit_uv.stencil_ibuf = NULL; - pd->edit_uv.stencil_image = NULL; + pd->edit_uv.stencil_ibuf = nullptr; + pd->edit_uv.stencil_image = nullptr; } if (pd->edit_uv.do_mask_overlay) { @@ -397,8 +406,9 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) pd->edit_uv.image_aspect[1]); pd->edit_uv.mask_texture = mask_texture; DRW_shgroup_uniform_texture(grp, "imgTexture", mask_texture); - DRW_shgroup_uniform_vec4_copy(grp, "color", (float[4]){1.0f, 1.0f, 1.0f, 1.0f}); - DRW_shgroup_call_obmat(grp, geom, NULL); + const float4 color = {1.0f, 1.0f, 1.0f, 1.0f}; + DRW_shgroup_uniform_vec4_copy(grp, "color", color); + DRW_shgroup_call_obmat(grp, geom, nullptr); } /* HACK: When editing objects that share the same mesh we should only draw the @@ -408,7 +418,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata) draw_ctx->obact->type == OB_MESH) { uint objects_len = 0; Object **objects = BKE_view_layer_array_from_objects_in_mode_unique_data( - draw_ctx->scene, draw_ctx->view_layer, NULL, &objects_len, draw_ctx->object_mode); + draw_ctx->scene, draw_ctx->view_layer, nullptr, &objects_len, draw_ctx->object_mode); for (uint ob_index = 0; ob_index < objects_len; ob_index++) { Object *object_eval = DEG_get_evaluated_object(draw_ctx->depsgraph, objects[ob_index]); DRW_mesh_batch_cache_validate(object_eval, (Mesh *)object_eval->data); @@ -440,26 +450,26 @@ static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob) if (has_active_edit_uvmap) { if (pd->edit_uv.do_uv_overlay) { - geom = DRW_mesh_batch_cache_get_edituv_edges(ob, ob->data); + geom = DRW_mesh_batch_cache_get_edituv_edges(ob, me); if (geom) { - DRW_shgroup_call_obmat(pd->edit_uv_edges_grp, geom, NULL); + DRW_shgroup_call_obmat(pd->edit_uv_edges_grp, geom, nullptr); } if (pd->edit_uv.do_verts) { - geom = DRW_mesh_batch_cache_get_edituv_verts(ob, ob->data); + geom = DRW_mesh_batch_cache_get_edituv_verts(ob, me); if (geom) { - DRW_shgroup_call_obmat(pd->edit_uv_verts_grp, geom, NULL); + DRW_shgroup_call_obmat(pd->edit_uv_verts_grp, geom, nullptr); } } if (pd->edit_uv.do_faces) { - geom = DRW_mesh_batch_cache_get_edituv_faces(ob, ob->data); + geom = DRW_mesh_batch_cache_get_edituv_faces(ob, me); if (geom) { - DRW_shgroup_call_obmat(pd->edit_uv_faces_grp, geom, NULL); + DRW_shgroup_call_obmat(pd->edit_uv_faces_grp, geom, nullptr); } } if (pd->edit_uv.do_face_dots) { - geom = DRW_mesh_batch_cache_get_edituv_facedots(ob, ob->data); + geom = DRW_mesh_batch_cache_get_edituv_facedots(ob, me); if (geom) { - DRW_shgroup_call_obmat(pd->edit_uv_face_dots_grp, geom, NULL); + DRW_shgroup_call_obmat(pd->edit_uv_face_dots_grp, geom, nullptr); } } } @@ -469,23 +479,23 @@ static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob) geom = DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(ob, me); } else /* SI_UVDT_STRETCH_AREA */ { - OVERLAY_StretchingAreaTotals *totals = MEM_mallocN(sizeof(OVERLAY_StretchingAreaTotals), - __func__); + OVERLAY_StretchingAreaTotals *totals = static_cast( + MEM_mallocN(sizeof(OVERLAY_StretchingAreaTotals), __func__)); BLI_addtail(&pd->edit_uv.totals, totals); geom = DRW_mesh_batch_cache_get_edituv_faces_stretch_area( ob, me, &totals->total_area, &totals->total_area_uv); } if (geom) { - DRW_shgroup_call_obmat(pd->edit_uv_stretching_grp, geom, NULL); + DRW_shgroup_call_obmat(pd->edit_uv_stretching_grp, geom, nullptr); } } } if (draw_shadows && (has_active_object_uvmap || has_active_edit_uvmap)) { if (pd->edit_uv.do_uv_shadow_overlay) { - geom = DRW_mesh_batch_cache_get_uv_edges(ob, ob->data); + geom = DRW_mesh_batch_cache_get_uv_edges(ob, me); if (geom) { - DRW_shgroup_call_obmat(pd->edit_uv_shadow_edges_grp, geom, NULL); + DRW_shgroup_call_obmat(pd->edit_uv_shadow_edges_grp, geom, nullptr); } } } @@ -530,8 +540,8 @@ static void OVERLAY_edit_uv_draw_finish(OVERLAY_Data *vedata) if (pd->edit_uv.stencil_ibuf) { BKE_image_release_ibuf( pd->edit_uv.stencil_image, pd->edit_uv.stencil_ibuf, pd->edit_uv.stencil_lock); - pd->edit_uv.stencil_image = NULL; - pd->edit_uv.stencil_ibuf = NULL; + pd->edit_uv.stencil_image = nullptr; + pd->edit_uv.stencil_ibuf = nullptr; } DRW_TEXTURE_FREE_SAFE(pd->edit_uv.mask_texture); @@ -550,7 +560,7 @@ void OVERLAY_edit_uv_draw(OVERLAY_Data *vedata) /* Combined overlay renders in the default framebuffer and modifies the image in SRS. * The alpha overlay renders in the overlay framebuffer. */ const bool is_combined_overlay = pd->edit_uv.mask_overlay_mode == MASK_OVERLAY_COMBINED; - GPUFrameBuffer *previous_framebuffer = NULL; + GPUFrameBuffer *previous_framebuffer = nullptr; if (is_combined_overlay) { DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); previous_framebuffer = GPU_framebuffer_active_get(); diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.cc similarity index 72% rename from source/blender/draw/engines/overlay/overlay_engine.c rename to source/blender/draw/engines/overlay/overlay_engine.cc index 6e2da95e405..9ee7cc4a10c 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.cc @@ -22,7 +22,7 @@ #include "DNA_space_types.h" #include "overlay_engine.h" -#include "overlay_private.h" +#include "overlay_private.hh" /* -------------------------------------------------------------------- */ /** \name Engine Callbacks @@ -30,7 +30,7 @@ static void OVERLAY_engine_init(void *vedata) { - OVERLAY_Data *data = vedata; + OVERLAY_Data *data = static_cast(vedata); OVERLAY_StorageList *stl = data->stl; const DRWContextState *draw_ctx = DRW_context_state_get(); const RegionView3D *rv3d = draw_ctx->rv3d; @@ -40,28 +40,29 @@ static void OVERLAY_engine_init(void *vedata) if (!stl->pd) { /* Allocate transient pointers. */ - stl->pd = MEM_callocN(sizeof(*stl->pd), __func__); + stl->pd = static_cast(MEM_callocN(sizeof(*stl->pd), __func__)); } /* Allocate instance. */ - if (data->instance == NULL) { - data->instance = MEM_callocN(sizeof(*data->instance), __func__); + if (data->instance == nullptr) { + data->instance = static_cast( + MEM_callocN(sizeof(*data->instance), __func__)); } OVERLAY_PrivateData *pd = stl->pd; - pd->space_type = v3d != NULL ? SPACE_VIEW3D : draw_ctx->space_data->spacetype; + pd->space_type = v3d != nullptr ? SPACE_VIEW3D : draw_ctx->space_data->spacetype; if (pd->space_type == SPACE_IMAGE) { const SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; pd->hide_overlays = (sima->overlay.flag & SI_OVERLAY_SHOW_OVERLAYS) == 0; - pd->clipping_state = 0; + pd->clipping_state = DRWState(0); OVERLAY_grid_init(data); OVERLAY_edit_uv_init(data); return; } if (pd->space_type == SPACE_NODE) { pd->hide_overlays = true; - pd->clipping_state = 0; + pd->clipping_state = DRWState(0); return; } @@ -101,98 +102,99 @@ static void OVERLAY_engine_init(void *vedata) pd->use_in_front = (v3d->shading.type <= OB_SOLID) || BKE_scene_uses_blender_workbench(draw_ctx->scene); pd->wireframe_mode = (v3d->shading.type == OB_WIRE); - pd->clipping_state = RV3D_CLIPPING_ENABLED(v3d, rv3d) ? DRW_STATE_CLIP_PLANES : 0; + pd->clipping_state = RV3D_CLIPPING_ENABLED(v3d, rv3d) ? DRW_STATE_CLIP_PLANES : DRWState(0); pd->xray_opacity = XRAY_ALPHA(v3d); pd->xray_enabled = XRAY_ACTIVE(v3d); pd->xray_enabled_and_not_wire = pd->xray_enabled && v3d->shading.type > OB_WIRE; pd->clear_in_front = (v3d->shading.type != OB_SOLID); pd->cfra = DEG_get_ctime(draw_ctx->depsgraph); - OVERLAY_antialiasing_init(vedata); + OVERLAY_antialiasing_init(data); switch (stl->pd->ctx_mode) { case CTX_MODE_EDIT_MESH: - OVERLAY_edit_mesh_init(vedata); + OVERLAY_edit_mesh_init(data); break; case CTX_MODE_EDIT_CURVES: - OVERLAY_edit_curves_init(vedata); + OVERLAY_edit_curves_init(data); break; default: /* Nothing to do. */ break; } - OVERLAY_facing_init(vedata); - OVERLAY_grid_init(vedata); - OVERLAY_image_init(vedata); - OVERLAY_outline_init(vedata); - OVERLAY_wireframe_init(vedata); - OVERLAY_paint_init(vedata); + OVERLAY_facing_init(data); + OVERLAY_grid_init(data); + OVERLAY_image_init(data); + OVERLAY_outline_init(data); + OVERLAY_wireframe_init(data); + OVERLAY_paint_init(data); } static void OVERLAY_cache_init(void *vedata) { - OVERLAY_Data *data = vedata; + OVERLAY_Data *data = static_cast(vedata); OVERLAY_StorageList *stl = data->stl; OVERLAY_PrivateData *pd = stl->pd; if (pd->space_type == SPACE_IMAGE) { - OVERLAY_background_cache_init(vedata); - OVERLAY_grid_cache_init(vedata); - OVERLAY_edit_uv_cache_init(vedata); + OVERLAY_background_cache_init(data); + OVERLAY_grid_cache_init(data); + OVERLAY_edit_uv_cache_init(data); return; } if (pd->space_type == SPACE_NODE) { - OVERLAY_background_cache_init(vedata); + OVERLAY_background_cache_init(data); return; } switch (pd->ctx_mode) { - case CTX_MODE_EDIT_MESH: - OVERLAY_edit_mesh_cache_init(vedata); + case CTX_MODE_EDIT_MESH: { + OVERLAY_edit_mesh_cache_init(data); /* `pd->edit_mesh.flag` is valid after calling `OVERLAY_edit_mesh_cache_init`. */ const bool draw_edit_weights = (pd->edit_mesh.flag & V3D_OVERLAY_EDIT_WEIGHT); if (draw_edit_weights) { - OVERLAY_paint_cache_init(vedata); + OVERLAY_paint_cache_init(data); } break; + } case CTX_MODE_EDIT_SURFACE: case CTX_MODE_EDIT_CURVE: - OVERLAY_edit_curve_cache_init(vedata); + OVERLAY_edit_curve_cache_init(data); break; case CTX_MODE_EDIT_TEXT: - OVERLAY_edit_text_cache_init(vedata); + OVERLAY_edit_text_cache_init(data); break; case CTX_MODE_EDIT_ARMATURE: break; case CTX_MODE_EDIT_METABALL: break; case CTX_MODE_EDIT_LATTICE: - OVERLAY_edit_lattice_cache_init(vedata); + OVERLAY_edit_lattice_cache_init(data); break; case CTX_MODE_PARTICLE: - OVERLAY_edit_particle_cache_init(vedata); + OVERLAY_edit_particle_cache_init(data); break; case CTX_MODE_POSE: case CTX_MODE_PAINT_WEIGHT: case CTX_MODE_PAINT_VERTEX: case CTX_MODE_PAINT_TEXTURE: - OVERLAY_paint_cache_init(vedata); + OVERLAY_paint_cache_init(data); break; case CTX_MODE_SCULPT: - OVERLAY_sculpt_cache_init(vedata); + OVERLAY_sculpt_cache_init(data); break; case CTX_MODE_EDIT_GPENCIL: case CTX_MODE_PAINT_GPENCIL: case CTX_MODE_SCULPT_GPENCIL: case CTX_MODE_VERTEX_GPENCIL: case CTX_MODE_WEIGHT_GPENCIL: - OVERLAY_edit_gpencil_cache_init(vedata); + OVERLAY_edit_gpencil_cache_init(data); break; case CTX_MODE_EDIT_CURVES: - OVERLAY_edit_curves_cache_init(vedata); + OVERLAY_edit_curves_cache_init(data); break; case CTX_MODE_SCULPT_CURVES: - OVERLAY_sculpt_curves_cache_init(vedata); + OVERLAY_sculpt_curves_cache_init(data); break; case CTX_MODE_OBJECT: break; @@ -200,22 +202,22 @@ static void OVERLAY_cache_init(void *vedata) BLI_assert_msg(0, "Draw mode invalid"); break; } - OVERLAY_antialiasing_cache_init(vedata); - OVERLAY_armature_cache_init(vedata); - OVERLAY_background_cache_init(vedata); - OVERLAY_fade_cache_init(vedata); - OVERLAY_mode_transfer_cache_init(vedata); - OVERLAY_extra_cache_init(vedata); - OVERLAY_facing_cache_init(vedata); - OVERLAY_gpencil_cache_init(vedata); - OVERLAY_grid_cache_init(vedata); - OVERLAY_image_cache_init(vedata); - OVERLAY_metaball_cache_init(vedata); - OVERLAY_motion_path_cache_init(vedata); - OVERLAY_outline_cache_init(vedata); - OVERLAY_particle_cache_init(vedata); - OVERLAY_wireframe_cache_init(vedata); - OVERLAY_volume_cache_init(vedata); + OVERLAY_antialiasing_cache_init(data); + OVERLAY_armature_cache_init(data); + OVERLAY_background_cache_init(data); + OVERLAY_fade_cache_init(data); + OVERLAY_mode_transfer_cache_init(data); + OVERLAY_extra_cache_init(data); + OVERLAY_facing_cache_init(data); + OVERLAY_gpencil_cache_init(data); + OVERLAY_grid_cache_init(data); + OVERLAY_image_cache_init(data); + OVERLAY_metaball_cache_init(data); + OVERLAY_motion_path_cache_init(data); + OVERLAY_outline_cache_init(data); + OVERLAY_particle_cache_init(data); + OVERLAY_wireframe_cache_init(data); + OVERLAY_volume_cache_init(data); } BLI_INLINE OVERLAY_DupliData *OVERLAY_duplidata_get(Object *ob, void *vedata, bool *do_init) @@ -223,12 +225,13 @@ BLI_INLINE OVERLAY_DupliData *OVERLAY_duplidata_get(Object *ob, void *vedata, bo OVERLAY_DupliData **dupli_data = (OVERLAY_DupliData **)DRW_duplidata_get(vedata); *do_init = false; if (!ELEM(ob->type, OB_MESH, OB_SURF, OB_LATTICE, OB_CURVES_LEGACY, OB_FONT)) { - return NULL; + return nullptr; } if (dupli_data) { - if (*dupli_data == NULL) { - *dupli_data = MEM_callocN(sizeof(OVERLAY_DupliData), __func__); + if (*dupli_data == nullptr) { + *dupli_data = static_cast( + MEM_callocN(sizeof(OVERLAY_DupliData), __func__)); *do_init = true; } else if ((*dupli_data)->base_flag != ob->base_flag) { @@ -237,7 +240,7 @@ BLI_INLINE OVERLAY_DupliData *OVERLAY_duplidata_get(Object *ob, void *vedata, bo } return *dupli_data; } - return NULL; + return nullptr; } static bool overlay_object_is_edit_mode(const OVERLAY_PrivateData *pd, const Object *ob) @@ -289,7 +292,7 @@ static bool overlay_should_fade_object(Object *ob, Object *active_object) static void OVERLAY_cache_populate(void *vedata, Object *ob) { - OVERLAY_Data *data = vedata; + OVERLAY_Data *data = static_cast(vedata); OVERLAY_PrivateData *pd = data->stl->pd; if (pd->space_type == SPACE_IMAGE) { @@ -312,7 +315,7 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) (draw_ctx->object_mode & OB_MODE_ALL_PAINT); const bool in_sculpt_curve_mode = (ob == draw_ctx->obact) && (draw_ctx->object_mode & OB_MODE_SCULPT_CURVES); - const bool in_sculpt_mode = (ob == draw_ctx->obact) && (ob->sculpt != NULL) && + const bool in_sculpt_mode = (ob == draw_ctx->obact) && (ob->sculpt != nullptr) && (ob->sculpt->mode_type == OB_MODE_SCULPT); const bool in_curves_sculpt_mode = (ob == draw_ctx->obact) && (ob->mode == OB_MODE_SCULPT_CURVES); @@ -353,108 +356,108 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) OVERLAY_DupliData *dupli = OVERLAY_duplidata_get(ob, vedata, &do_init); if (draw_fade) { - OVERLAY_fade_cache_populate(vedata, ob); + OVERLAY_fade_cache_populate(data, ob); } if (draw_facing) { - OVERLAY_facing_cache_populate(vedata, ob); + OVERLAY_facing_cache_populate(data, ob); } if (draw_mode_transfer) { - OVERLAY_mode_transfer_cache_populate(vedata, ob); + OVERLAY_mode_transfer_cache_populate(data, ob); } if (draw_wires) { - OVERLAY_wireframe_cache_populate(vedata, ob, dupli, do_init); + OVERLAY_wireframe_cache_populate(data, ob, dupli, do_init); } if (draw_outlines) { - OVERLAY_outline_cache_populate(vedata, ob, dupli, do_init); + OVERLAY_outline_cache_populate(data, ob, dupli, do_init); } if (draw_bone_selection) { - OVERLAY_pose_cache_populate(vedata, ob); + OVERLAY_pose_cache_populate(data, ob); } if (ob->type == OB_VOLUME) { - OVERLAY_volume_cache_populate(vedata, ob); + OVERLAY_volume_cache_populate(data, ob); } if (in_edit_mode && !pd->hide_overlays) { switch (ob->type) { case OB_MESH: - OVERLAY_edit_mesh_cache_populate(vedata, ob); + OVERLAY_edit_mesh_cache_populate(data, ob); if (draw_edit_weights) { - OVERLAY_paint_weight_cache_populate(vedata, ob); + OVERLAY_paint_weight_cache_populate(data, ob); } break; case OB_ARMATURE: if (draw_bones) { - OVERLAY_edit_armature_cache_populate(vedata, ob); + OVERLAY_edit_armature_cache_populate(data, ob); } break; case OB_CURVES_LEGACY: - OVERLAY_edit_curve_cache_populate(vedata, ob); + OVERLAY_edit_curve_cache_populate(data, ob); break; case OB_SURF: - OVERLAY_edit_surf_cache_populate(vedata, ob); + OVERLAY_edit_surf_cache_populate(data, ob); break; case OB_LATTICE: - OVERLAY_edit_lattice_cache_populate(vedata, ob); + OVERLAY_edit_lattice_cache_populate(data, ob); break; case OB_MBALL: - OVERLAY_edit_metaball_cache_populate(vedata, ob); + OVERLAY_edit_metaball_cache_populate(data, ob); break; case OB_FONT: - OVERLAY_edit_text_cache_populate(vedata, ob); + OVERLAY_edit_text_cache_populate(data, ob); break; case OB_CURVES: - OVERLAY_edit_curves_cache_populate(vedata, ob); + OVERLAY_edit_curves_cache_populate(data, ob); break; } } else if (in_pose_mode && draw_bones) { - OVERLAY_pose_armature_cache_populate(vedata, ob); + OVERLAY_pose_armature_cache_populate(data, ob); } else if (in_paint_mode && !pd->hide_overlays) { switch (draw_ctx->object_mode) { case OB_MODE_VERTEX_PAINT: - OVERLAY_paint_vertex_cache_populate(vedata, ob); + OVERLAY_paint_vertex_cache_populate(data, ob); break; case OB_MODE_WEIGHT_PAINT: - OVERLAY_paint_weight_cache_populate(vedata, ob); + OVERLAY_paint_weight_cache_populate(data, ob); break; case OB_MODE_TEXTURE_PAINT: - OVERLAY_paint_texture_cache_populate(vedata, ob); + OVERLAY_paint_texture_cache_populate(data, ob); break; default: break; } } else if (in_particle_edit_mode) { - OVERLAY_edit_particle_cache_populate(vedata, ob); + OVERLAY_edit_particle_cache_populate(data, ob); } if (in_sculpt_mode) { - OVERLAY_sculpt_cache_populate(vedata, ob); + OVERLAY_sculpt_cache_populate(data, ob); } else if (in_curves_sculpt_mode) { - OVERLAY_sculpt_curves_cache_populate(vedata, ob); + OVERLAY_sculpt_curves_cache_populate(data, ob); } if (draw_motion_paths) { - OVERLAY_motion_path_cache_populate(vedata, ob); + OVERLAY_motion_path_cache_populate(data, ob); } if (!pd->hide_overlays) { switch (ob->type) { case OB_ARMATURE: if (draw_bones && (is_select || (!in_edit_mode && !in_pose_mode))) { - OVERLAY_armature_cache_populate(vedata, ob); + OVERLAY_armature_cache_populate(data, ob); } break; case OB_MBALL: if (!in_edit_mode) { - OVERLAY_metaball_cache_populate(vedata, ob); + OVERLAY_metaball_cache_populate(data, ob); } break; case OB_GPENCIL: - OVERLAY_gpencil_cache_populate(vedata, ob); + OVERLAY_gpencil_cache_populate(data, ob); break; } } @@ -462,25 +465,25 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) if (draw_extras) { switch (ob->type) { case OB_EMPTY: - OVERLAY_empty_cache_populate(vedata, ob); + OVERLAY_empty_cache_populate(data, ob); break; case OB_LAMP: - OVERLAY_light_cache_populate(vedata, ob); + OVERLAY_light_cache_populate(data, ob); break; case OB_CAMERA: - OVERLAY_camera_cache_populate(vedata, ob); + OVERLAY_camera_cache_populate(data, ob); break; case OB_SPEAKER: - OVERLAY_speaker_cache_populate(vedata, ob); + OVERLAY_speaker_cache_populate(data, ob); break; case OB_LIGHTPROBE: - OVERLAY_lightprobe_cache_populate(vedata, ob); + OVERLAY_lightprobe_cache_populate(data, ob); break; case OB_LATTICE: { /* Unlike the other types above, lattices actually have a bounding box defined, so hide the * lattice wires if only the bounding-box is requested. */ if (ob->dt > OB_BOUNDBOX) { - OVERLAY_lattice_cache_populate(vedata, ob); + OVERLAY_lattice_cache_populate(data, ob); } break; } @@ -488,12 +491,12 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) } if (!BLI_listbase_is_empty(&ob->particlesystem)) { - OVERLAY_particle_cache_populate(vedata, ob); + OVERLAY_particle_cache_populate(data, ob); } /* Relationship, object center, bounding-box... etc. */ if (!pd->hide_overlays) { - OVERLAY_extra_cache_populate(vedata, ob); + OVERLAY_extra_cache_populate(data, ob); } if (dupli) { @@ -503,11 +506,11 @@ static void OVERLAY_cache_populate(void *vedata, Object *ob) static void OVERLAY_cache_finish(void *vedata) { - OVERLAY_Data *data = vedata; + OVERLAY_Data *data = static_cast(vedata); OVERLAY_PrivateData *pd = data->stl->pd; if (ELEM(pd->space_type, SPACE_IMAGE)) { - OVERLAY_edit_uv_cache_finish(vedata); + OVERLAY_edit_uv_cache_finish(data); return; } if (ELEM(pd->space_type, SPACE_NODE)) { @@ -520,29 +523,30 @@ static void OVERLAY_cache_finish(void *vedata) DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - DRW_texture_ensure_fullscreen_2d(&dtxl->depth_in_front, GPU_DEPTH24_STENCIL8, 0); + DRW_texture_ensure_fullscreen_2d( + &dtxl->depth_in_front, GPU_DEPTH24_STENCIL8, DRWTextureFlag(0)); GPU_framebuffer_ensure_config( &dfbl->in_front_fb, {GPU_ATTACHMENT_TEXTURE(dtxl->depth_in_front), GPU_ATTACHMENT_TEXTURE(dtxl->color)}); } - OVERLAY_mode_transfer_cache_finish(vedata); - OVERLAY_antialiasing_cache_finish(vedata); - OVERLAY_armature_cache_finish(vedata); - OVERLAY_image_cache_finish(vedata); + OVERLAY_mode_transfer_cache_finish(data); + OVERLAY_antialiasing_cache_finish(data); + OVERLAY_armature_cache_finish(data); + OVERLAY_image_cache_finish(data); } static void OVERLAY_draw_scene(void *vedata) { - OVERLAY_Data *data = vedata; + OVERLAY_Data *data = static_cast(vedata); OVERLAY_PrivateData *pd = data->stl->pd; OVERLAY_FramebufferList *fbl = data->fbl; DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); /* Needs to be done first as it modifies the scene color and depth buffer. */ if (pd->space_type == SPACE_VIEW3D) { - OVERLAY_image_scene_background_draw(vedata); + OVERLAY_image_scene_background_draw(data); } if (DRW_state_is_fbo()) { @@ -569,45 +573,45 @@ static void OVERLAY_draw_scene(void *vedata) return; } - OVERLAY_image_background_draw(vedata); - OVERLAY_background_draw(vedata); + OVERLAY_image_background_draw(data); + OVERLAY_background_draw(data); - OVERLAY_antialiasing_start(vedata); + OVERLAY_antialiasing_start(data); - DRW_view_set_active(NULL); + DRW_view_set_active(nullptr); if (DRW_state_is_fbo()) { GPU_framebuffer_bind(fbl->overlay_color_only_fb); } - OVERLAY_outline_draw(vedata); - OVERLAY_xray_depth_copy(vedata); + OVERLAY_outline_draw(data); + OVERLAY_xray_depth_copy(data); if (DRW_state_is_fbo()) { GPU_framebuffer_bind(fbl->overlay_default_fb); } - OVERLAY_image_draw(vedata); - OVERLAY_fade_draw(vedata); - OVERLAY_facing_draw(vedata); - OVERLAY_mode_transfer_draw(vedata); - OVERLAY_extra_blend_draw(vedata); - OVERLAY_volume_draw(vedata); + OVERLAY_image_draw(data); + OVERLAY_fade_draw(data); + OVERLAY_facing_draw(data); + OVERLAY_mode_transfer_draw(data); + OVERLAY_extra_blend_draw(data); + OVERLAY_volume_draw(data); /* These overlays are drawn here to avoid artifacts with wire-frame opacity. */ switch (pd->ctx_mode) { case CTX_MODE_SCULPT: - OVERLAY_sculpt_draw(vedata); + OVERLAY_sculpt_draw(data); break; case CTX_MODE_SCULPT_CURVES: - OVERLAY_sculpt_curves_draw(vedata); + OVERLAY_sculpt_curves_draw(data); break; case CTX_MODE_EDIT_MESH: case CTX_MODE_POSE: case CTX_MODE_PAINT_WEIGHT: case CTX_MODE_PAINT_VERTEX: case CTX_MODE_PAINT_TEXTURE: - OVERLAY_paint_draw(vedata); + OVERLAY_paint_draw(data); break; default: break; @@ -617,46 +621,46 @@ static void OVERLAY_draw_scene(void *vedata) GPU_framebuffer_bind(fbl->overlay_line_fb); } - OVERLAY_wireframe_draw(vedata); - OVERLAY_armature_draw(vedata); - OVERLAY_particle_draw(vedata); - OVERLAY_metaball_draw(vedata); - OVERLAY_gpencil_draw(vedata); - OVERLAY_extra_draw(vedata); + OVERLAY_wireframe_draw(data); + OVERLAY_armature_draw(data); + OVERLAY_particle_draw(data); + OVERLAY_metaball_draw(data); + OVERLAY_gpencil_draw(data); + OVERLAY_extra_draw(data); if (DRW_state_is_fbo()) { GPU_framebuffer_bind(fbl->overlay_color_only_fb); } - OVERLAY_xray_fade_draw(vedata); - OVERLAY_grid_draw(vedata); + OVERLAY_xray_fade_draw(data); + OVERLAY_grid_draw(data); - OVERLAY_xray_depth_infront_copy(vedata); + OVERLAY_xray_depth_infront_copy(data); if (DRW_state_is_fbo()) { GPU_framebuffer_bind(fbl->overlay_in_front_fb); } - OVERLAY_fade_infront_draw(vedata); - OVERLAY_facing_infront_draw(vedata); - OVERLAY_mode_transfer_infront_draw(vedata); + OVERLAY_fade_infront_draw(data); + OVERLAY_facing_infront_draw(data); + OVERLAY_mode_transfer_infront_draw(data); if (DRW_state_is_fbo()) { GPU_framebuffer_bind(fbl->overlay_line_in_front_fb); } - OVERLAY_wireframe_in_front_draw(vedata); - OVERLAY_armature_in_front_draw(vedata); - OVERLAY_extra_in_front_draw(vedata); - OVERLAY_metaball_in_front_draw(vedata); + OVERLAY_wireframe_in_front_draw(data); + OVERLAY_armature_in_front_draw(data); + OVERLAY_extra_in_front_draw(data); + OVERLAY_metaball_in_front_draw(data); if (DRW_state_is_fbo()) { GPU_framebuffer_bind(fbl->overlay_color_only_fb); } - OVERLAY_image_in_front_draw(vedata); - OVERLAY_motion_path_draw(vedata); - OVERLAY_extra_centers_draw(vedata); + OVERLAY_image_in_front_draw(data); + OVERLAY_motion_path_draw(data); + OVERLAY_extra_centers_draw(data); if (DRW_state_is_select() || DRW_state_is_depth()) { /* Edit modes have their own selection code. */ @@ -667,41 +671,41 @@ static void OVERLAY_draw_scene(void *vedata) switch (pd->ctx_mode) { case CTX_MODE_EDIT_MESH: - OVERLAY_edit_mesh_draw(vedata); + OVERLAY_edit_mesh_draw(data); break; case CTX_MODE_EDIT_SURFACE: case CTX_MODE_EDIT_CURVE: - OVERLAY_edit_curve_draw(vedata); + OVERLAY_edit_curve_draw(data); break; case CTX_MODE_EDIT_TEXT: - OVERLAY_edit_text_draw(vedata); + OVERLAY_edit_text_draw(data); break; case CTX_MODE_EDIT_LATTICE: - OVERLAY_edit_lattice_draw(vedata); + OVERLAY_edit_lattice_draw(data); break; case CTX_MODE_POSE: - OVERLAY_pose_draw(vedata); + OVERLAY_pose_draw(data); break; case CTX_MODE_PARTICLE: - OVERLAY_edit_particle_draw(vedata); + OVERLAY_edit_particle_draw(data); break; case CTX_MODE_EDIT_GPENCIL: case CTX_MODE_PAINT_GPENCIL: case CTX_MODE_SCULPT_GPENCIL: case CTX_MODE_VERTEX_GPENCIL: case CTX_MODE_WEIGHT_GPENCIL: - OVERLAY_edit_gpencil_draw(vedata); + OVERLAY_edit_gpencil_draw(data); break; case CTX_MODE_SCULPT_CURVES: break; case CTX_MODE_EDIT_CURVES: - OVERLAY_edit_curves_draw(vedata); + OVERLAY_edit_curves_draw(data); break; default: break; } - OVERLAY_antialiasing_end(vedata); + OVERLAY_antialiasing_end(data); } static void OVERLAY_engine_free(void) @@ -725,8 +729,8 @@ static void OVERLAY_instance_free(void *instance_) static const DrawEngineDataSize overlay_data_size = DRW_VIEWPORT_DATA_SIZE(OVERLAY_Data); DrawEngineType draw_engine_overlay_type = { - NULL, - NULL, + nullptr, + nullptr, N_("Overlay"), &overlay_data_size, &OVERLAY_engine_init, @@ -736,10 +740,10 @@ DrawEngineType draw_engine_overlay_type = { &OVERLAY_cache_populate, &OVERLAY_cache_finish, &OVERLAY_draw_scene, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, }; /** \} */ diff --git a/source/blender/draw/engines/overlay/overlay_engine.h b/source/blender/draw/engines/overlay/overlay_engine.h index 18ab7f1456e..a33ea17dc1e 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.h +++ b/source/blender/draw/engines/overlay/overlay_engine.h @@ -7,4 +7,12 @@ #pragma once +#ifdef __cplusplus +extern "C" { +#endif + extern DrawEngineType draw_engine_overlay_type; + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.cc similarity index 97% rename from source/blender/draw/engines/overlay/overlay_extra.c rename to source/blender/draw/engines/overlay/overlay_extra.cc index 5d80ab3d0ea..8dd2f0d9a85 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.cc @@ -38,7 +38,7 @@ #include "ED_view3d.h" -#include "overlay_private.h" +#include "overlay_private.hh" #include "draw_common.h" #include "draw_manager_text.h" @@ -79,7 +79,8 @@ void OVERLAY_extra_cache_init(OVERLAY_Data *vedata) OVERLAY_ExtraCallBuffers *cb = &pd->extra_call_buffers[i]; DRWPass **p_extra_ps = &psl->extra_ps[i]; - DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : 0; + DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : + DRWState(0); DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; DRW_PASS_CREATE(*p_extra_ps, state | pd->clipping_state | infront_state); @@ -352,7 +353,7 @@ static void OVERLAY_bounds(OVERLAY_ExtraCallBuffers *cb, const BoundBox *bb = BKE_object_boundbox_get(ob); BoundBox bb_local; - if (bb == NULL) { + if (bb == nullptr) { const float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {1.0f, 1.0f, 1.0f}; BKE_boundbox_init_from_minmax(&bb_local, min, max); bb = &bb_local; @@ -443,17 +444,17 @@ static void OVERLAY_collision(OVERLAY_ExtraCallBuffers *cb, Object *ob, const fl static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, const float *color) { - if (ob->data == NULL) { + if (ob->data == nullptr) { return; } - ID *ob_data = ob->data; - float *texcoloc = NULL; - float *texcosize = NULL; + ID *ob_data = static_cast(ob->data); + float *texcoloc = nullptr; + float *texcosize = nullptr; switch (GS(ob_data->name)) { case ID_ME: - BKE_mesh_texspace_get_reference((Mesh *)ob_data, NULL, &texcoloc, &texcosize); + BKE_mesh_texspace_get_reference((Mesh *)ob_data, nullptr, &texcoloc, &texcosize); break; case ID_CU_LEGACY: { Curve *cu = (Curve *)ob_data; @@ -480,7 +481,7 @@ static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, cons float mat[4][4]; - if (texcoloc != NULL && texcosize != NULL) { + if (texcoloc != nullptr && texcosize != nullptr) { size_to_mat4(mat, texcosize); copy_v3_v3(mat[3], texcoloc); } @@ -495,10 +496,10 @@ static void OVERLAY_texture_space(OVERLAY_ExtraCallBuffers *cb, Object *ob, cons static void OVERLAY_forcefield(OVERLAY_ExtraCallBuffers *cb, Object *ob, ViewLayer *view_layer) { - int theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); + int theme_id = DRW_object_wire_theme_get(ob, view_layer, nullptr); float *color = DRW_color_background_blend_get(theme_id); PartDeflect *pd = ob->pd; - Curve *cu = (ob->type == OB_CURVES_LEGACY) ? ob->data : NULL; + Curve *cu = (ob->type == OB_CURVES_LEGACY) ? static_cast(ob->data) : nullptr; union { float mat[4][4]; @@ -529,12 +530,12 @@ static void OVERLAY_forcefield(OVERLAY_ExtraCallBuffers *cb, Object *ob, ViewLay if (cu && (cu->flag & CU_PATH) && ob->runtime.curve_cache->anim_path_accum_length) { instdata.size_x = instdata.size_y = instdata.size_z = pd->f_strength; float pos[4]; - BKE_where_on_path(ob, 0.0f, pos, NULL, NULL, NULL, NULL); + BKE_where_on_path(ob, 0.0f, pos, nullptr, nullptr, nullptr, nullptr); copy_v3_v3(instdata.pos, ob->obmat[3]); translate_m4(instdata.mat, pos[0], pos[1], pos[2]); DRW_buffer_add_entry(cb->field_curve, color, &instdata); - BKE_where_on_path(ob, 1.0f, pos, NULL, NULL, NULL, NULL); + BKE_where_on_path(ob, 1.0f, pos, nullptr, nullptr, nullptr, nullptr); copy_v3_v3(instdata.pos, ob->obmat[3]); translate_m4(instdata.mat, pos[0], pos[1], pos[2]); DRW_buffer_add_entry(cb->field_sphere_limit, color, &instdata); @@ -600,7 +601,7 @@ void OVERLAY_light_cache_populate(OVERLAY_Data *vedata, Object *ob) const DRWContextState *draw_ctx = DRW_context_state_get(); ViewLayer *view_layer = draw_ctx->view_layer; - Light *la = ob->data; + Light *la = static_cast(ob->data); float *color_p; DRW_object_wire_theme_get(ob, view_layer, &color_p); /* Remove the alpha. */ @@ -644,7 +645,8 @@ void OVERLAY_light_cache_populate(OVERLAY_Data *vedata, Object *ob) else if (la->type == LA_SPOT) { /* Previous implementation was using the clipend distance as cone size. * We cannot do this anymore so we use a fixed size of 10. (see T72871) */ - rescale_m4(instdata.mat, (float[3]){10.0f, 10.0f, 10.0f}); + const float3 scale_vec = {10.0f, 10.0f, 10.0f}; + rescale_m4(instdata.mat, scale_vec); /* For cycles and eevee the spot attenuation is * y = (1/(1 + x^2) - a)/((1 - a) b) * We solve the case where spot attenuation y = 1 and y = 0 @@ -756,7 +758,7 @@ void OVERLAY_lightprobe_cache_populate(OVERLAY_Data *vedata, Object *ob) uint cell_count = prb->grid_resolution_x * prb->grid_resolution_y * prb->grid_resolution_z; DRWShadingGroup *grp = DRW_shgroup_create_sub(vedata->stl->pd->extra_grid_grp); DRW_shgroup_uniform_mat4_copy(grp, "gridModelMatrix", instdata.mat); - DRW_shgroup_call_procedural_points(grp, NULL, cell_count); + DRW_shgroup_call_procedural_points(grp, nullptr, cell_count); } break; case LIGHTPROBE_TYPE_PLANAR: @@ -849,7 +851,7 @@ static void camera_view3d_reconstruction( const bool is_select = DRW_state_is_select(); MovieClip *clip = BKE_object_movieclip_get(scene, ob, false); - if (clip == NULL) { + if (clip == nullptr) { return; } @@ -985,7 +987,7 @@ static float camera_offaxis_shiftx_get(Scene *scene, const OVERLAY_CameraInstanceData *instdata, bool right_eye) { - Camera *cam = ob->data; + Camera *cam = static_cast(ob->data); if (cam->stereo.convergence_mode == CAM_S3D_OFFAXIS) { const char *viewnames[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; const float shiftx = BKE_camera_multiview_shift_x(&scene->r, ob, viewnames[right_eye]); @@ -1007,7 +1009,7 @@ static void camera_stereoscopy_extra(OVERLAY_ExtraCallBuffers *cb, const OVERLAY_CameraInstanceData *instdata) { OVERLAY_CameraInstanceData stereodata = *instdata; - Camera *cam = ob->data; + Camera *cam = static_cast(ob->data); const bool is_select = DRW_state_is_select(); const char *viewnames[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME}; @@ -1111,7 +1113,7 @@ void OVERLAY_camera_cache_populate(OVERLAY_Data *vedata, Object *ob) Scene *scene = draw_ctx->scene; RegionView3D *rv3d = draw_ctx->rv3d; - Camera *cam = ob->data; + Camera *cam = static_cast(ob->data); Object *camera_object = DEG_get_evaluated_object(draw_ctx->depsgraph, v3d->camera); const bool is_select = DRW_state_is_select(); const bool is_active = (ob == camera_object); @@ -1257,7 +1259,7 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, } /* Drawing the hook lines. */ - for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + for (ModifierData *md = static_cast(ob->modifiers.first); md; md = md->next) { if (md->type == eModifierType_Hook) { HookModifierData *hmd = (HookModifierData *)md; float center[3]; @@ -1286,14 +1288,14 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, bConstraintOb *cob; ListBase *list = &ob->constraints; - cob = BKE_constraints_make_evalob(depsgraph, scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); + cob = BKE_constraints_make_evalob(depsgraph, scene, ob, nullptr, CONSTRAINT_OBTYPE_OBJECT); - for (curcon = list->first; curcon; curcon = curcon->next) { + for (curcon = static_cast(list->first); curcon; curcon = curcon->next) { if (ELEM(curcon->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_OBJECTSOLVER)) { /* special case for object solver and follow track constraints because they don't fill * constraint targets properly (design limitation -- scene is needed for their target * but it can't be accessed from get_targets callback) */ - Object *camob = NULL; + Object *camob = nullptr; if (curcon->type == CONSTRAINT_TYPE_FOLLOWTRACK) { bFollowTrackConstraint *data = (bFollowTrackConstraint *)curcon->data; @@ -1310,14 +1312,14 @@ static void OVERLAY_relationship_lines(OVERLAY_ExtraCallBuffers *cb, } else { const bConstraintTypeInfo *cti = BKE_constraint_typeinfo_get(curcon); - ListBase targets = {NULL, NULL}; + ListBase targets = {nullptr, nullptr}; if ((curcon->ui_expand_flag & (1 << 0)) && BKE_constraint_targets_get(curcon, &targets)) { bConstraintTarget *ct; BKE_constraint_custom_object_space_init(cob, curcon); - for (ct = targets.first; ct; ct = ct->next) { + for (ct = static_cast(targets.first); ct; ct = ct->next) { /* calculate target's matrix */ if (ct->flag & CONSTRAINT_TAR_CUSTOM_SPACE) { copy_m4_m4(ct->matrix, cob->space_obj_world_matrix); @@ -1394,7 +1396,7 @@ static void OVERLAY_volume_extra(OVERLAY_ExtraCallBuffers *cb, if (fds->axis_slice_method == AXIS_SLICE_SINGLE) { float viewinv[4][4]; - DRW_view_viewmat_get(NULL, viewinv, true); + DRW_view_viewmat_get(nullptr, viewinv, true); const int axis = (fds->slice_axis == SLICE_AXIS_AUTO) ? axis_dominant_v3_single(viewinv[2]) : fds->slice_axis - 1; @@ -1527,7 +1529,7 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob) const DRWContextState *draw_ctx = DRW_context_state_get(); ViewLayer *view_layer = draw_ctx->view_layer; Scene *scene = draw_ctx->scene; - ModifierData *md = NULL; + ModifierData *md = nullptr; const bool is_select_mode = DRW_state_is_select(); const bool is_paint_mode = (draw_ctx->object_mode & @@ -1551,7 +1553,7 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob) const bool draw_volume = !from_dupli && (md = BKE_modifiers_findby_type(ob, eModifierType_Fluid)) && (BKE_modifier_is_enabled(scene, md, eModifierMode_Realtime)) && - (((FluidModifierData *)md)->domain != NULL) && + (((FluidModifierData *)md)->domain != nullptr) && (scene->r.cfra >= (((FluidModifierData *)md)->domain->cache_frame_start)) && (scene->r.cfra <= (((FluidModifierData *)md)->domain->cache_frame_end)); @@ -1585,7 +1587,7 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob) if (draw_texspace) { OVERLAY_texture_space(cb, ob, color); } - if (ob->rigidbody_object != NULL) { + if (ob->rigidbody_object != nullptr) { OVERLAY_collision(cb, ob, color); } if (ob->dtx & OB_AXIS) { diff --git a/source/blender/draw/engines/overlay/overlay_facing.c b/source/blender/draw/engines/overlay/overlay_facing.cc similarity index 98% rename from source/blender/draw/engines/overlay/overlay_facing.c rename to source/blender/draw/engines/overlay/overlay_facing.cc index bf06600eb33..9a501c8f1bb 100644 --- a/source/blender/draw/engines/overlay/overlay_facing.c +++ b/source/blender/draw/engines/overlay/overlay_facing.cc @@ -8,7 +8,7 @@ #include "BKE_paint.h" #include "DRW_render.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_facing_init(OVERLAY_Data *UNUSED(vedata)) { diff --git a/source/blender/draw/engines/overlay/overlay_fade.c b/source/blender/draw/engines/overlay/overlay_fade.cc similarity index 98% rename from source/blender/draw/engines/overlay/overlay_fade.c rename to source/blender/draw/engines/overlay/overlay_fade.cc index 056e02a04e1..138226c3e2e 100644 --- a/source/blender/draw/engines/overlay/overlay_fade.c +++ b/source/blender/draw/engines/overlay/overlay_fade.cc @@ -10,7 +10,7 @@ #include "ED_view3d.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_fade_init(OVERLAY_Data *UNUSED(vedata)) { diff --git a/source/blender/draw/engines/overlay/overlay_gpencil.c b/source/blender/draw/engines/overlay/overlay_gpencil.cc similarity index 91% rename from source/blender/draw/engines/overlay/overlay_gpencil.c rename to source/blender/draw/engines/overlay/overlay_gpencil.cc index 9531b0dd983..f72bf81bf57 100644 --- a/source/blender/draw/engines/overlay/overlay_gpencil.c +++ b/source/blender/draw/engines/overlay/overlay_gpencil.cc @@ -17,7 +17,7 @@ #include "ED_view3d.h" -#include "overlay_private.h" +#include "overlay_private.hh" #include "draw_common.h" #include "draw_manager_text.h" @@ -30,22 +30,22 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata) DRWShadingGroup *grp; /* Default: Display nothing. */ - pd->edit_gpencil_points_grp = NULL; - pd->edit_gpencil_wires_grp = NULL; - psl->edit_gpencil_ps = NULL; + pd->edit_gpencil_points_grp = nullptr; + pd->edit_gpencil_wires_grp = nullptr; + psl->edit_gpencil_ps = nullptr; - pd->edit_gpencil_curve_handle_grp = NULL; - pd->edit_gpencil_curve_points_grp = NULL; - psl->edit_gpencil_curve_ps = NULL; + pd->edit_gpencil_curve_handle_grp = nullptr; + pd->edit_gpencil_curve_points_grp = nullptr; + psl->edit_gpencil_curve_ps = nullptr; const DRWContextState *draw_ctx = DRW_context_state_get(); View3D *v3d = draw_ctx->v3d; Object *ob = draw_ctx->obact; - bGPdata *gpd = ob ? (bGPdata *)ob->data : NULL; + bGPdata *gpd = ob ? (bGPdata *)ob->data : nullptr; Scene *scene = draw_ctx->scene; ToolSettings *ts = scene->toolsettings; - if (gpd == NULL || ob->type != OB_GPENCIL) { + if (gpd == nullptr || ob->type != OB_GPENCIL) { return; } @@ -169,14 +169,14 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata) sh = OVERLAY_shader_edit_gpencil_guide_point(); grp = DRW_shgroup_create(sh, psl->edit_gpencil_gizmos_ps); - if (gpd->runtime.cp_points != NULL) { + if (gpd->runtime.cp_points != nullptr) { for (int i = 0; i < gpd->runtime.tot_cp_points; i++) { bGPDcontrolpoint *cp = &gpd->runtime.cp_points[i]; grp = DRW_shgroup_create_sub(grp); DRW_shgroup_uniform_vec3_copy(grp, "pPosition", &cp->x); DRW_shgroup_uniform_float_copy(grp, "pSize", cp->size * 0.8f * G_draw.block.size_pixel); DRW_shgroup_uniform_vec4_copy(grp, "pColor", cp->color); - DRW_shgroup_call_procedural_points(grp, NULL, 1); + DRW_shgroup_call_procedural_points(grp, nullptr, 1); } } @@ -187,7 +187,7 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec3_copy(grp, "pPosition", ts->gp_sculpt.guide.location); } else if (ts->gp_sculpt.guide.reference_point == GP_GUIDE_REF_OBJECT && - ts->gp_sculpt.guide.reference_object != NULL) { + ts->gp_sculpt.guide.reference_object != nullptr) { UI_GetThemeColor4fv(TH_GIZMO_SECONDARY, color); DRW_shgroup_uniform_vec3_copy(grp, "pPosition", ts->gp_sculpt.guide.reference_object->loc); } @@ -197,7 +197,7 @@ void OVERLAY_edit_gpencil_cache_init(OVERLAY_Data *vedata) } DRW_shgroup_uniform_vec4_copy(grp, "pColor", color); DRW_shgroup_uniform_float_copy(grp, "pSize", 8.0f * G_draw.block.size_pixel); - DRW_shgroup_call_procedural_points(grp, NULL, 1); + DRW_shgroup_call_procedural_points(grp, nullptr, 1); } } } @@ -210,12 +210,12 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata) DRWShadingGroup *grp; /* Default: Display nothing. */ - psl->gpencil_canvas_ps = NULL; + psl->gpencil_canvas_ps = nullptr; const DRWContextState *draw_ctx = DRW_context_state_get(); View3D *v3d = draw_ctx->v3d; Object *ob = draw_ctx->obact; - bGPdata *gpd = ob ? (bGPdata *)ob->data : NULL; + bGPdata *gpd = ob ? (bGPdata *)ob->data : nullptr; Scene *scene = draw_ctx->scene; ToolSettings *ts = scene->toolsettings; const View3DCursor *cursor = &scene->cursor; @@ -223,7 +223,7 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata) pd->edit_curve.show_handles = v3d->overlay.handle_display != CURVE_HANDLE_NONE; pd->edit_curve.handle_display = v3d->overlay.handle_display; - if (gpd == NULL || ob->type != OB_GPENCIL) { + if (gpd == nullptr || ob->type != OB_GPENCIL) { return; } @@ -234,7 +234,7 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata) const bool grid_xray = (v3d->gp_flag & V3D_GP_SHOW_GRID_XRAY); if (show_grid && show_overlays) { - const char *grid_unit = NULL; + const char *grid_unit = nullptr; float mat[4][4]; float col_grid[4]; float size[2]; @@ -247,7 +247,7 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata) /* Rotate and scale except align to cursor. */ bGPDlayer *gpl = BKE_gpencil_layer_active_get(gpd); - if (gpl != NULL) { + if (gpl != nullptr) { if (ts->gp_sculpt.lock_axis != GP_LOCKAXIS_CURSOR) { float matrot[3][3]; copy_m3_m4(matrot, gpl->layer_mat); @@ -267,12 +267,14 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata) case GP_LOCKAXIS_Z: /* Default. */ break; - case GP_LOCKAXIS_CURSOR: - loc_eul_size_to_mat4(mat, cursor->location, cursor->rotation_euler, (float[3]){1, 1, 1}); + case GP_LOCKAXIS_CURSOR: { + const float3 size_vec = {1.0f, 1.0f, 1.0f}; + loc_eul_size_to_mat4(mat, cursor->location, cursor->rotation_euler, size_vec); break; + } case GP_LOCKAXIS_VIEW: /* view aligned */ - DRW_view_viewmat_get(NULL, viewinv, true); + DRW_view_viewmat_get(nullptr, viewinv, true); copy_v3_v3(mat[0], viewinv[0]); copy_v3_v3(mat[1], viewinv[1]); break; @@ -289,10 +291,11 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata) translate_m4(mat, gpd->grid.offset[0], gpd->grid.offset[1], 0.0f); mul_v2_v2fl(size, gpd->grid.scale, 2.0f * ED_scene_grid_scale(scene, &grid_unit)); - rescale_m4(mat, (float[3]){size[0], size[1], 0.0f}); + const float3 scale_vec = {size[0], size[1], 0.0f}; + rescale_m4(mat, scale_vec); /* Apply layer loc transform, except cursor mode. */ - if ((gpl != NULL) && (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) { + if ((gpl != nullptr) && (ts->gpencil_v3d_align & GP_PROJECT_CURSOR) == 0) { add_v3_v3(mat[3], gpl->layer_mat[3]); } @@ -312,7 +315,7 @@ void OVERLAY_gpencil_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_vec3_copy(grp, "yAxis", mat[1]); DRW_shgroup_uniform_vec3_copy(grp, "origin", mat[3]); DRW_shgroup_uniform_int_copy(grp, "halfLineCount", line_count / 2); - DRW_shgroup_call_procedural_lines(grp, NULL, line_count); + DRW_shgroup_call_procedural_lines(grp, nullptr, line_count); } } @@ -368,12 +371,12 @@ static void overlay_gpencil_draw_stroke_color_name(bGPDlayer *UNUSED(gpl), { Object *ob = (Object *)thunk; Material *ma = BKE_object_material_get_eval(ob, gps->mat_nr + 1); - if (ma == NULL) { + if (ma == nullptr) { return; } MaterialGPencilStyle *gp_style = ma->gp_style; /* skip stroke if it doesn't have any valid data */ - if ((gps->points == NULL) || (gps->totpoints < 1) || (gp_style == NULL)) { + if ((gps->points == nullptr) || (gps->totpoints < 1) || (gp_style == nullptr)) { return; } /* check if the color is visible */ @@ -389,7 +392,7 @@ static void overlay_gpencil_draw_stroke_color_name(bGPDlayer *UNUSED(gpl), const DRWContextState *draw_ctx = DRW_context_state_get(); ViewLayer *view_layer = draw_ctx->view_layer; - int theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL); + int theme_id = DRW_object_wire_theme_get(ob, view_layer, nullptr); uchar color[4]; UI_GetThemeColor4ubv(theme_id, color); @@ -417,7 +420,7 @@ static void OVERLAY_gpencil_color_names(Object *ob) int cfra = DEG_get_ctime(draw_ctx->depsgraph); BKE_gpencil_visible_stroke_advanced_iter( - NULL, ob, NULL, overlay_gpencil_draw_stroke_color_name, ob, false, cfra); + nullptr, ob, nullptr, overlay_gpencil_draw_stroke_color_name, ob, false, cfra); } void OVERLAY_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob) @@ -426,7 +429,7 @@ void OVERLAY_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob) View3D *v3d = draw_ctx->v3d; bGPdata *gpd = (bGPdata *)ob->data; - if (gpd == NULL) { + if (gpd == nullptr) { return; } diff --git a/source/blender/draw/engines/overlay/overlay_grid.c b/source/blender/draw/engines/overlay/overlay_grid.cc similarity index 94% rename from source/blender/draw/engines/overlay/overlay_grid.c rename to source/blender/draw/engines/overlay/overlay_grid.cc index e424f49455b..71abcf91223 100644 --- a/source/blender/draw/engines/overlay/overlay_grid.c +++ b/source/blender/draw/engines/overlay/overlay_grid.cc @@ -17,7 +17,7 @@ #include "UI_resources.h" -#include "overlay_private.h" +#include "overlay_private.hh" BLI_STATIC_ASSERT(SI_GRID_STEPS_LEN == OVERLAY_GRID_STEPS_LEN, "") @@ -31,10 +31,11 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) float *zplane_axes = pd->grid.zplane_axes; float grid_steps[SI_GRID_STEPS_LEN] = { 0.001f, 0.01f, 0.1f, 1.0f, 10.0f, 100.0f, 1000.0f, 10000.0f}; - OVERLAY_GridBits grid_flag = 0, zneg_flag = 0, zpos_flag = 0; + OVERLAY_GridBits grid_flag = OVERLAY_GridBits(0), zneg_flag = OVERLAY_GridBits(0), + zpos_flag = OVERLAY_GridBits(0); grid->line_size = max_ff(0.0f, U.pixelsize - 1.0f) * 0.5f; /* Default, nothing is drawn. */ - pd->grid.grid_flag = pd->grid.zneg_flag = pd->grid.zpos_flag = 0; + pd->grid.grid_flag = pd->grid.zneg_flag = pd->grid.zpos_flag = OVERLAY_GridBits(0); if (pd->space_type == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)draw_ctx->space_data; @@ -88,10 +89,10 @@ void OVERLAY_grid_init(OVERLAY_Data *vedata) float viewinv[4][4], wininv[4][4]; float viewmat[4][4], winmat[4][4]; - DRW_view_winmat_get(NULL, winmat, false); - DRW_view_winmat_get(NULL, wininv, true); - DRW_view_viewmat_get(NULL, viewmat, false); - DRW_view_viewmat_get(NULL, viewinv, true); + DRW_view_winmat_get(nullptr, winmat, false); + DRW_view_winmat_get(nullptr, wininv, true); + DRW_view_viewmat_get(nullptr, viewmat, false); + DRW_view_viewmat_get(nullptr, viewinv, true); /* If perspective view or non-axis aligned view. */ if (winmat[3][3] == 0.0f || rv3d->view == RV3D_VIEW_USER) { @@ -211,13 +212,13 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *ved) OVERLAY_PassList *psl = ved->psl; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - psl->grid_ps = NULL; + psl->grid_ps = nullptr; if ((pd->grid.grid_flag == 0 && pd->grid.zpos_flag == 0) || !DRW_state_is_fbo()) { return; } - if (ved->instance->grid_ubo == NULL) { + if (ved->instance->grid_ubo == nullptr) { ved->instance->grid_ubo = GPU_uniformbuf_create(sizeof(OVERLAY_GridData)); } GPU_uniformbuf_update(ved->instance->grid_ubo, &pd->grid_data); @@ -257,21 +258,21 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *ved) DRW_shgroup_uniform_int_copy(grp, "grid_flag", pd->grid.zneg_flag); DRW_shgroup_uniform_vec3_copy(grp, "plane_axes", pd->grid.zplane_axes); if (pd->grid.zneg_flag & SHOW_AXIS_Z) { - DRW_shgroup_call(grp, geom, NULL); + DRW_shgroup_call(grp, geom, nullptr); } grp = DRW_shgroup_create_sub(grp); DRW_shgroup_uniform_int_copy(grp, "grid_flag", pd->grid.grid_flag); DRW_shgroup_uniform_vec3_copy(grp, "plane_axes", pd->grid.grid_axes); if (pd->grid.grid_flag) { - DRW_shgroup_call(grp, geom, NULL); + DRW_shgroup_call(grp, geom, nullptr); } grp = DRW_shgroup_create_sub(grp); DRW_shgroup_uniform_int_copy(grp, "grid_flag", pd->grid.zpos_flag); DRW_shgroup_uniform_vec3_copy(grp, "plane_axes", pd->grid.zplane_axes); if (pd->grid.zpos_flag & SHOW_AXIS_Z) { - DRW_shgroup_call(grp, geom, NULL); + DRW_shgroup_call(grp, geom, nullptr); } } diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.cc similarity index 93% rename from source/blender/draw/engines/overlay/overlay_image.c rename to source/blender/draw/engines/overlay/overlay_image.cc index 3e9c05bb59f..dff30eed620 100644 --- a/source/blender/draw/engines/overlay/overlay_image.c +++ b/source/blender/draw/engines/overlay/overlay_image.cc @@ -23,7 +23,7 @@ #include "IMB_imbuf_types.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_image_init(OVERLAY_Data *vedata) { @@ -99,10 +99,10 @@ static eStereoViews camera_background_images_stereo_eye(const Scene *scene, cons } if (v3d->stereo3d_camera != STEREO_3D_ID) { /* show only left or right camera */ - return v3d->stereo3d_camera; + return eStereoViews(v3d->stereo3d_camera); } - return v3d->multiview_eye; + return eStereoViews(v3d->multiview_eye); } static void camera_background_images_stereo_setup(const Scene *scene, @@ -130,8 +130,8 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp void *lock; Image *image = bgpic->ima; ImageUser *iuser = &bgpic->iuser; - MovieClip *clip = NULL; - GPUTexture *tex = NULL; + MovieClip *clip = nullptr; + GPUTexture *tex = nullptr; Scene *scene = draw_ctx->scene; float aspect_x, aspect_y; int width, height; @@ -140,9 +140,9 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp *r_use_view_transform = false; switch (bgpic->source) { - case CAM_BGIMG_SOURCE_IMAGE: - if (image == NULL) { - return NULL; + case CAM_BGIMG_SOURCE_IMAGE: { + if (image == nullptr) { + return nullptr; } *r_use_alpha_premult = (image->alpha_mode == IMA_ALPHA_PREMUL); *r_use_view_transform = (image->flag & IMA_VIEW_AS_RENDER) != 0; @@ -150,33 +150,34 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp BKE_image_user_frame_calc(image, iuser, ctime); if (image->source == IMA_SRC_SEQUENCE && !(iuser->flag & IMA_USER_FRAME_IN_RANGE)) { /* Frame is out of range, don't show. */ - return NULL; + return nullptr; } camera_background_images_stereo_setup(scene, draw_ctx->v3d, image, iuser); iuser->scene = draw_ctx->scene; ImBuf *ibuf = BKE_image_acquire_ibuf(image, iuser, &lock); - if (ibuf == NULL) { + if (ibuf == nullptr) { BKE_image_release_ibuf(image, ibuf, lock); - iuser->scene = NULL; - return NULL; + iuser->scene = nullptr; + return nullptr; } width = ibuf->x; height = ibuf->y; tex = BKE_image_get_gpu_texture(image, iuser, ibuf); BKE_image_release_ibuf(image, ibuf, lock); - iuser->scene = NULL; + iuser->scene = nullptr; - if (tex == NULL) { - return NULL; + if (tex == nullptr) { + return nullptr; } aspect_x = bgpic->ima->aspx; aspect_y = bgpic->ima->aspy; break; + } - case CAM_BGIMG_SOURCE_MOVIE: + case CAM_BGIMG_SOURCE_MOVIE: { if (bgpic->flag & CAM_BGIMG_FLAG_CAMERACLIP) { if (scene->camera) { clip = BKE_object_movieclip_get(scene, scene->camera, true); @@ -186,14 +187,14 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp clip = bgpic->clip; } - if (clip == NULL) { - return NULL; + if (clip == nullptr) { + return nullptr; } BKE_movieclip_user_set_frame(&bgpic->cuser, ctime); tex = BKE_movieclip_get_gpu_texture(clip, &bgpic->cuser); - if (tex == NULL) { - return NULL; + if (tex == nullptr) { + return nullptr; } aspect_x = clip->aspx; @@ -205,10 +206,11 @@ static struct GPUTexture *image_camera_background_texture_get(CameraBGImage *bgp /* Save for freeing. */ BLI_addtail(&pd->bg_movie_clips, BLI_genericNodeN(clip)); break; + } default: /* Unsupported type. */ - return NULL; + return nullptr; } *r_aspect = (width * aspect_x) / (height * aspect_y); @@ -219,7 +221,7 @@ static void OVERLAY_image_free_movieclips_textures(OVERLAY_Data *data) { /* Free Movie clip textures after rendering */ LinkData *link; - while ((link = BLI_pophead(&data->stl->pd->bg_movie_clips))) { + while ((link = static_cast(BLI_pophead(&data->stl->pd->bg_movie_clips)))) { MovieClip *clip = (MovieClip *)link->data; BKE_movieclip_free_gputexture(clip); MEM_freeN(link); @@ -299,7 +301,7 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob) const DRWContextState *draw_ctx = DRW_context_state_get(); const View3D *v3d = draw_ctx->v3d; const Scene *scene = draw_ctx->scene; - Camera *cam = ob->data; + Camera *cam = static_cast(ob->data); const bool show_frame = BKE_object_empty_image_frame_is_visible_in_view3d(ob, draw_ctx->rv3d); @@ -333,7 +335,7 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob) /* Alpha is clamped just below 1.0 to fix background images to interfere with foreground * images. Without this a background image with 1.0 will be rendered on top of a transparent * foreground image due to the different blending modes they use. */ - const float color_premult_alpha[4] = {1.0f, 1.0f, 1.0f, MIN2(bgpic->alpha, 0.999999)}; + const float color_premult_alpha[4] = {1.0f, 1.0f, 1.0f, std::min(bgpic->alpha, 0.999999f)}; DRWPass *pass = is_foreground ? (use_view_transform ? psl->image_foreground_scene_ps : psl->image_foreground_ps) : @@ -358,8 +360,8 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob) OVERLAY_PassList *psl = vedata->psl; const DRWContextState *draw_ctx = DRW_context_state_get(); const RegionView3D *rv3d = draw_ctx->rv3d; - GPUTexture *tex = NULL; - Image *ima = ob->data; + GPUTexture *tex = nullptr; + Image *ima = static_cast(ob->data); float mat[4][4]; const bool show_frame = BKE_object_empty_image_frame_is_visible_in_view3d(ob, rv3d); @@ -375,10 +377,10 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob) /* Calling 'BKE_image_get_size' may free the texture. Get the size from 'tex' instead, * see: T59347 */ int size[2] = {0}; - if (ima != NULL) { + if (ima != nullptr) { ImageUser iuser = *ob->iuser; camera_background_images_stereo_setup(draw_ctx->scene, draw_ctx->v3d, ima, &iuser); - tex = BKE_image_get_gpu_texture(ima, &iuser, NULL); + tex = BKE_image_get_gpu_texture(ima, &iuser, nullptr); if (tex) { size[0] = GPU_texture_orig_width(tex); size[1] = GPU_texture_orig_height(tex); @@ -388,7 +390,7 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob) CLAMP_MIN(size[1], 1); float image_aspect[2]; - overlay_image_calc_aspect(ob->data, size, image_aspect); + overlay_image_calc_aspect(ima, size, image_aspect); copy_m4_m4(mat, ob->obmat); mul_v3_fl(mat[0], image_aspect[0] * 0.5f * ob->empty_drawsize); @@ -399,7 +401,7 @@ void OVERLAY_image_empty_cache_populate(OVERLAY_Data *vedata, Object *ob) /* Use the actual depth if we are doing depth tests to determine the distance to the object */ char depth_mode = DRW_state_is_depth() ? OB_EMPTY_IMAGE_DEPTH_DEFAULT : ob->empty_image_depth; - DRWPass *pass = NULL; + DRWPass *pass = nullptr; if ((ob->dtx & OB_DRAW_IN_FRONT) != 0) { /* Object In Front overrides image empty depth mode. */ pass = psl->image_empties_front_ps; @@ -479,7 +481,7 @@ void OVERLAY_image_draw(OVERLAY_Data *vedata) DRW_draw_pass(psl->image_empties_ps); DRW_draw_pass(psl->image_empties_blend_ps); - DRW_view_set_active(NULL); + DRW_view_set_active(nullptr); } void OVERLAY_image_in_front_draw(OVERLAY_Data *vedata) @@ -492,7 +494,7 @@ void OVERLAY_image_in_front_draw(OVERLAY_Data *vedata) DRW_draw_pass(psl->image_empties_front_ps); DRW_draw_pass(psl->image_foreground_ps); - DRW_view_set_active(NULL); + DRW_view_set_active(nullptr); OVERLAY_image_free_movieclips_textures(vedata); } diff --git a/source/blender/draw/engines/overlay/overlay_lattice.c b/source/blender/draw/engines/overlay/overlay_lattice.cc similarity index 98% rename from source/blender/draw/engines/overlay/overlay_lattice.c rename to source/blender/draw/engines/overlay/overlay_lattice.cc index 2035a9a9d3b..7b59aa78c89 100644 --- a/source/blender/draw/engines/overlay/overlay_lattice.c +++ b/source/blender/draw/engines/overlay/overlay_lattice.cc @@ -7,7 +7,7 @@ #include "DRW_render.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_edit_lattice_cache_init(OVERLAY_Data *vedata) { diff --git a/source/blender/draw/engines/overlay/overlay_metaball.c b/source/blender/draw/engines/overlay/overlay_metaball.cc similarity index 94% rename from source/blender/draw/engines/overlay/overlay_metaball.c rename to source/blender/draw/engines/overlay/overlay_metaball.cc index f024f5dfac8..38de273028b 100644 --- a/source/blender/draw/engines/overlay/overlay_metaball.c +++ b/source/blender/draw/engines/overlay/overlay_metaball.cc @@ -15,7 +15,7 @@ #include "ED_mball.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_metaball_cache_init(OVERLAY_Data *vedata) { @@ -27,7 +27,8 @@ void OVERLAY_metaball_cache_init(OVERLAY_Data *vedata) #define BUF_INSTANCE DRW_shgroup_call_buffer_instance for (int i = 0; i < 2; i++) { - DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : 0; + DRWState infront_state = (DRW_state_is_select() && (i == 1)) ? DRW_STATE_IN_FRONT_SELECT : + DRWState(0); DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH | DRW_STATE_DEPTH_LESS_EQUAL; DRW_PASS_CREATE(psl->metaball_ps[i], state | pd->clipping_state | infront_state); @@ -57,7 +58,7 @@ void OVERLAY_edit_metaball_cache_populate(OVERLAY_Data *vedata, Object *ob) const bool do_in_front = (ob->dtx & OB_DRAW_IN_FRONT) != 0; const bool is_select = DRW_state_is_select(); OVERLAY_PrivateData *pd = vedata->stl->pd; - MetaBall *mb = ob->data; + MetaBall *mb = static_cast(ob->data); const float *color; const float *col_radius = G_draw.block.color_mball_radius; @@ -103,7 +104,7 @@ void OVERLAY_metaball_cache_populate(OVERLAY_Data *vedata, Object *ob) { const bool do_in_front = (ob->dtx & OB_DRAW_IN_FRONT) != 0; OVERLAY_PrivateData *pd = vedata->stl->pd; - MetaBall *mb = ob->data; + MetaBall *mb = static_cast(ob->data); const DRWContextState *draw_ctx = DRW_context_state_get(); float *color; diff --git a/source/blender/draw/engines/overlay/overlay_mode_transfer.c b/source/blender/draw/engines/overlay/overlay_mode_transfer.cc similarity index 99% rename from source/blender/draw/engines/overlay/overlay_mode_transfer.c rename to source/blender/draw/engines/overlay/overlay_mode_transfer.cc index e7b2008dee0..d4bc5655da3 100644 --- a/source/blender/draw/engines/overlay/overlay_mode_transfer.c +++ b/source/blender/draw/engines/overlay/overlay_mode_transfer.cc @@ -13,7 +13,7 @@ #include "PIL_time.h" #include "UI_resources.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_mode_transfer_cache_init(OVERLAY_Data *vedata) { diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.c b/source/blender/draw/engines/overlay/overlay_motion_path.cc similarity index 95% rename from source/blender/draw/engines/overlay/overlay_motion_path.c rename to source/blender/draw/engines/overlay/overlay_motion_path.cc index 58825923f37..00b2a8665fd 100644 --- a/source/blender/draw/engines/overlay/overlay_motion_path.c +++ b/source/blender/draw/engines/overlay/overlay_motion_path.cc @@ -20,7 +20,7 @@ #include "draw_manager_text.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_motion_path_cache_init(OVERLAY_Data *vedata) { @@ -63,7 +63,7 @@ static GPUVertBuf *mpath_vbo_get(bMotionPath *mpath) static GPUBatch *mpath_batch_line_get(bMotionPath *mpath) { if (!mpath->batch_line) { - mpath->batch_line = GPU_batch_create(GPU_PRIM_LINE_STRIP, mpath_vbo_get(mpath), NULL); + mpath->batch_line = GPU_batch_create(GPU_PRIM_LINE_STRIP, mpath_vbo_get(mpath), nullptr); } return mpath->batch_line; } @@ -71,7 +71,7 @@ static GPUBatch *mpath_batch_line_get(bMotionPath *mpath) static GPUBatch *mpath_batch_points_get(bMotionPath *mpath) { if (!mpath->batch_points) { - mpath->batch_points = GPU_batch_create(GPU_PRIM_POINTS, mpath_vbo_get(mpath), NULL); + mpath->batch_points = GPU_batch_create(GPU_PRIM_POINTS, mpath_vbo_get(mpath), nullptr); } return mpath->batch_points; } @@ -143,7 +143,7 @@ static void motion_path_cache(OVERLAY_Data *vedata, DRW_shgroup_uniform_bool_copy(grp, "selected", selected); DRW_shgroup_uniform_vec3_copy(grp, "customColor", color); /* Only draw the required range. */ - DRW_shgroup_call_range(grp, NULL, mpath_batch_line_get(mpath), start_index, len); + DRW_shgroup_call_range(grp, nullptr, mpath_batch_line_get(mpath), start_index, len); } /* Draw points. */ @@ -155,7 +155,7 @@ static void motion_path_cache(OVERLAY_Data *vedata, DRW_shgroup_uniform_bool_copy(grp, "showKeyFrames", show_keyframes); DRW_shgroup_uniform_vec3_copy(grp, "customColor", color); /* Only draw the required range. */ - DRW_shgroup_call_range(grp, NULL, mpath_batch_points_get(mpath), start_index, len); + DRW_shgroup_call_range(grp, nullptr, mpath_batch_points_get(mpath), start_index, len); } /* Draw frame numbers at each frame-step value. */ @@ -208,7 +208,7 @@ void OVERLAY_motion_path_cache_populate(OVERLAY_Data *vedata, Object *ob) } if (ob->mpath) { - motion_path_cache(vedata, ob, NULL, &ob->avs, ob->mpath); + motion_path_cache(vedata, ob, nullptr, &ob->avs, ob->mpath); } } diff --git a/source/blender/draw/engines/overlay/overlay_outline.c b/source/blender/draw/engines/overlay/overlay_outline.cc similarity index 94% rename from source/blender/draw/engines/overlay/overlay_outline.c rename to source/blender/draw/engines/overlay/overlay_outline.cc index f2e2acc98a9..e308775dc6e 100644 --- a/source/blender/draw/engines/overlay/overlay_outline.c +++ b/source/blender/draw/engines/overlay/overlay_outline.cc @@ -16,14 +16,14 @@ #include "UI_resources.h" -#include "overlay_private.h" +#include "overlay_private.hh" /* Returns the normal plane in NDC space. */ static void gpencil_depth_plane(Object *ob, float r_plane[4]) { /* TODO: put that into private data. */ float viewinv[4][4]; - DRW_view_viewmat_get(NULL, viewinv, true); + DRW_view_viewmat_get(nullptr, viewinv, true); float *camera_z_axis = viewinv[2]; float *camera_pos = viewinv[3]; @@ -47,7 +47,7 @@ static void gpencil_depth_plane(Object *ob, float r_plane[4]) /* BBox center in world space. */ copy_v3_v3(center, mat[3]); /* View Vector. */ - if (DRW_view_is_persp_get(NULL)) { + if (DRW_view_is_persp_get(nullptr)) { /* BBox center to camera vector. */ sub_v3_v3v3(r_plane, camera_pos, mat[3]); } @@ -78,8 +78,8 @@ void OVERLAY_outline_init(OVERLAY_Data *vedata) if (DRW_state_is_fbo()) { /* TODO: only alloc if needed. */ - DRW_texture_ensure_fullscreen_2d(&txl->temp_depth_tx, GPU_DEPTH24_STENCIL8, 0); - DRW_texture_ensure_fullscreen_2d(&txl->outlines_id_tx, GPU_R16UI, 0); + DRW_texture_ensure_fullscreen_2d(&txl->temp_depth_tx, GPU_DEPTH24_STENCIL8, DRWTextureFlag(0)); + DRW_texture_ensure_fullscreen_2d(&txl->outlines_id_tx, GPU_R16UI, DRWTextureFlag(0)); GPU_framebuffer_ensure_config( &fbl->outlines_prepass_fb, @@ -109,7 +109,7 @@ void OVERLAY_outline_cache_init(OVERLAY_Data *vedata) OVERLAY_TextureList *txl = vedata->txl; OVERLAY_PrivateData *pd = vedata->stl->pd; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - DRWShadingGroup *grp = NULL; + DRWShadingGroup *grp = nullptr; const float outline_width = UI_GetThemeValuef(TH_OUTLINE_WIDTH); const bool do_expand = (U.pixelsize > 1.0) || (outline_width > 2.0f); @@ -161,7 +161,7 @@ void OVERLAY_outline_cache_init(OVERLAY_Data *vedata) DRW_shgroup_uniform_texture_ref(grp, "sceneDepth", &dtxl->depth); DRW_shgroup_uniform_texture_ref(grp, "outlineDepth", &txl->temp_depth_tx); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); - DRW_shgroup_call_procedural_triangles(grp, NULL, 1); + DRW_shgroup_call_procedural_triangles(grp, nullptr, 1); } } @@ -240,18 +240,17 @@ static void OVERLAY_outline_gpencil(OVERLAY_PrivateData *pd, Object *ob) return; } - iterData iter = { - .ob = ob, - .stroke_grp = pd->outlines_gpencil_grp, - .fill_grp = DRW_shgroup_create_sub(pd->outlines_gpencil_grp), - .cfra = pd->cfra, - }; + iterData iter{}; + iter.ob = ob; + iter.stroke_grp = pd->outlines_gpencil_grp; + iter.fill_grp = DRW_shgroup_create_sub(pd->outlines_gpencil_grp); + iter.cfra = pd->cfra; if (gpd->draw_mode == GP_DRAWMODE_2D) { gpencil_depth_plane(ob, iter.plane); } - BKE_gpencil_visible_stroke_advanced_iter(NULL, + BKE_gpencil_visible_stroke_advanced_iter(nullptr, ob, gpencil_layer_cache_populate, gpencil_stroke_cache_populate, @@ -263,7 +262,7 @@ static void OVERLAY_outline_gpencil(OVERLAY_PrivateData *pd, Object *ob) static void OVERLAY_outline_volume(OVERLAY_PrivateData *pd, Object *ob) { struct GPUBatch *geom = DRW_cache_volume_selection_surface_get(ob); - if (geom == NULL) { + if (geom == nullptr) { return; } @@ -274,7 +273,7 @@ static void OVERLAY_outline_volume(OVERLAY_PrivateData *pd, Object *ob) static void OVERLAY_outline_curves(OVERLAY_PrivateData *pd, Object *ob) { DRWShadingGroup *shgroup = pd->outlines_curves_grp; - DRW_shgroup_curves_create_sub(ob, shgroup, NULL); + DRW_shgroup_curves_create_sub(ob, shgroup, nullptr); } void OVERLAY_outline_cache_populate(OVERLAY_Data *vedata, @@ -285,7 +284,7 @@ void OVERLAY_outline_cache_populate(OVERLAY_Data *vedata, OVERLAY_PrivateData *pd = vedata->stl->pd; const DRWContextState *draw_ctx = DRW_context_state_get(); struct GPUBatch *geom; - DRWShadingGroup *shgroup = NULL; + DRWShadingGroup *shgroup = nullptr; const bool draw_outline = ob->dt > OB_BOUNDBOX; /* Early exit: outlines of bounding boxes are not drawn. */ @@ -326,7 +325,7 @@ void OVERLAY_outline_cache_populate(OVERLAY_Data *vedata, DRW_object_axis_orthogonal_to_view(ob, flat_axis)); if (pd->xray_enabled_and_not_wire || is_flat_object_viewed_from_side) { - geom = DRW_cache_object_edge_detection_get(ob, NULL); + geom = DRW_cache_object_edge_detection_get(ob, nullptr); } else { geom = DRW_cache_object_surface_get(ob); @@ -359,7 +358,7 @@ void OVERLAY_outline_draw(OVERLAY_Data *vedata) OVERLAY_PassList *psl = vedata->psl; const float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - bool do_outlines = psl->outlines_prepass_ps != NULL && + bool do_outlines = psl->outlines_prepass_ps != nullptr && !DRW_pass_is_empty(psl->outlines_prepass_ps); if (DRW_state_is_fbo() && do_outlines) { diff --git a/source/blender/draw/engines/overlay/overlay_paint.c b/source/blender/draw/engines/overlay/overlay_paint.cc similarity index 93% rename from source/blender/draw/engines/overlay/overlay_paint.c rename to source/blender/draw/engines/overlay/overlay_paint.cc index c730c702a8d..d2573d1db0b 100644 --- a/source/blender/draw/engines/overlay/overlay_paint.c +++ b/source/blender/draw/engines/overlay/overlay_paint.cc @@ -13,7 +13,7 @@ #include "DEG_depsgraph_query.h" -#include "overlay_private.h" +#include "overlay_private.hh" /* Check if the given object is rendered (partially) transparent */ static bool paint_object_is_rendered_transparent(View3D *v3d, Object *ob) @@ -31,7 +31,7 @@ static bool paint_object_is_rendered_transparent(View3D *v3d, Object *ob) } if (ob && ob->type == OB_MESH && ob->data && v3d->shading.color_type == V3D_SHADING_MATERIAL_COLOR) { - Mesh *me = ob->data; + Mesh *me = static_cast(ob->data); for (int i = 0; i < me->totcol; i++) { Material *mat = BKE_object_material_get_eval(ob, i + 1); if (mat && mat->a < 1.0f) { @@ -74,8 +74,8 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata) const bool draw_contours = !is_edit_mode && (pd->overlay.wpaint_flag & V3D_OVERLAY_WPAINT_CONTOURS) != 0; float opacity = 0.0f; - pd->paint_depth_grp = NULL; - psl->paint_depth_ps = NULL; + pd->paint_depth_grp = nullptr; + psl->paint_depth_ps = nullptr; switch (pd->ctx_mode) { case CTX_MODE_POSE: @@ -130,14 +130,14 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata) case CTX_MODE_PAINT_TEXTURE: { const ImagePaintSettings *imapaint = &draw_ctx->scene->toolsettings->imapaint; const bool mask_enabled = imapaint->flag & IMAGEPAINT_PROJECT_LAYER_STENCIL && - imapaint->stencil != NULL; + imapaint->stencil != nullptr; opacity = mask_enabled ? pd->overlay.texture_paint_mode_opacity : 0.0f; if (opacity > 0.0f) { state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_BLEND_ALPHA; DRW_PASS_CREATE(psl->paint_color_ps, state | pd->clipping_state); - GPUTexture *tex = BKE_image_get_gpu_texture(imapaint->stencil, NULL, NULL); + GPUTexture *tex = BKE_image_get_gpu_texture(imapaint->stencil, nullptr, nullptr); const bool mask_premult = (imapaint->stencil->alpha_mode == IMA_ALPHA_PREMUL); const bool mask_inverted = (imapaint->flag & IMAGEPAINT_PROJECT_LAYER_STENCIL_INV) != 0; @@ -158,8 +158,8 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata) } if (opacity <= 0.0f) { - psl->paint_color_ps = NULL; - pd->paint_surf_grp = NULL; + psl->paint_color_ps = nullptr; + pd->paint_surf_grp = nullptr; } { @@ -167,7 +167,8 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata) DRW_PASS_CREATE(psl->paint_overlay_ps, state | pd->clipping_state); sh = OVERLAY_shader_paint_face(); pd->paint_face_grp = grp = DRW_shgroup_create(sh, psl->paint_overlay_ps); - DRW_shgroup_uniform_vec4_copy(grp, "color", (float[4]){1.0f, 1.0f, 1.0f, 0.2f}); + const float4 color = {1.0f, 1.0f, 1.0f, 0.2f}; + DRW_shgroup_uniform_vec4_copy(grp, "color", color); DRW_shgroup_state_enable(grp, DRW_STATE_BLEND_ALPHA); sh = OVERLAY_shader_paint_wire(); @@ -190,9 +191,9 @@ void OVERLAY_paint_cache_init(OVERLAY_Data *vedata) void OVERLAY_paint_texture_cache_populate(OVERLAY_Data *vedata, Object *ob) { OVERLAY_PrivateData *pd = vedata->stl->pd; - struct GPUBatch *geom = NULL; + struct GPUBatch *geom = nullptr; - const Mesh *me_orig = DEG_get_original_object(ob)->data; + const Mesh *me_orig = static_cast(DEG_get_original_object(ob)->data); const bool use_face_sel = (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; if (pd->paint_surf_grp) { @@ -209,9 +210,9 @@ void OVERLAY_paint_texture_cache_populate(OVERLAY_Data *vedata, Object *ob) void OVERLAY_paint_vertex_cache_populate(OVERLAY_Data *vedata, Object *ob) { OVERLAY_PrivateData *pd = vedata->stl->pd; - struct GPUBatch *geom = NULL; + struct GPUBatch *geom = nullptr; - const Mesh *me_orig = DEG_get_original_object(ob)->data; + const Mesh *me_orig = static_cast(DEG_get_original_object(ob)->data); const bool is_edit_mode = (pd->ctx_mode == CTX_MODE_EDIT_MESH); const bool use_wire = !is_edit_mode && (pd->overlay.paint_flag & V3D_OVERLAY_PAINT_WIRE); const bool use_face_sel = !is_edit_mode && (me_orig->editflag & ME_EDIT_PAINT_FACE_SEL); diff --git a/source/blender/draw/engines/overlay/overlay_particle.c b/source/blender/draw/engines/overlay/overlay_particle.cc similarity index 92% rename from source/blender/draw/engines/overlay/overlay_particle.c rename to source/blender/draw/engines/overlay/overlay_particle.cc index b985bfb24bf..6f77a777ba0 100644 --- a/source/blender/draw/engines/overlay/overlay_particle.c +++ b/source/blender/draw/engines/overlay/overlay_particle.cc @@ -15,7 +15,7 @@ #include "ED_particle.h" -#include "overlay_private.h" +#include "overlay_private.hh" /* -------------------------------------------------------------------- */ /** \name Edit Particles @@ -64,7 +64,7 @@ void OVERLAY_edit_particle_cache_populate(OVERLAY_Data *vedata, Object *ob) */ Object *ob_orig = DEG_get_original_object(ob); PTCacheEdit *edit = PE_create_current(draw_ctx->depsgraph, scene_orig, ob_orig); - if (edit == NULL) { + if (edit == nullptr) { /* Happens when trying to edit particles in EMITTER mode without * having them cached. */ @@ -73,14 +73,14 @@ void OVERLAY_edit_particle_cache_populate(OVERLAY_Data *vedata, Object *ob) /* NOTE: We need to pass evaluated particle system, which we need * to find first. */ - ParticleSystem *psys = ob->particlesystem.first; + ParticleSystem *psys = static_cast(ob->particlesystem.first); LISTBASE_FOREACH (ParticleSystem *, psys_orig, &ob_orig->particlesystem) { if (PE_get_current_from_psys(psys_orig) == edit) { break; } psys = psys->next; } - if (psys == NULL) { + if (psys == nullptr) { printf("Error getting evaluated particle system for edit.\n"); return; } @@ -88,17 +88,17 @@ void OVERLAY_edit_particle_cache_populate(OVERLAY_Data *vedata, Object *ob) struct GPUBatch *geom; { geom = DRW_cache_particles_get_edit_strands(ob, psys, edit, pd->edit_particle.use_weight); - DRW_shgroup_call(pd->edit_particle_strand_grp, geom, NULL); + DRW_shgroup_call(pd->edit_particle_strand_grp, geom, nullptr); } if (pd->edit_particle.select_mode == SCE_SELECT_POINT) { geom = DRW_cache_particles_get_edit_inner_points(ob, psys, edit); - DRW_shgroup_call(pd->edit_particle_point_grp, geom, NULL); + DRW_shgroup_call(pd->edit_particle_point_grp, geom, nullptr); } if (ELEM(pd->edit_particle.select_mode, SCE_SELECT_POINT, SCE_SELECT_END)) { geom = DRW_cache_particles_get_edit_tip_points(ob, psys, edit); - DRW_shgroup_call(pd->edit_particle_point_grp, geom, NULL); + DRW_shgroup_call(pd->edit_particle_point_grp, geom, nullptr); } } @@ -165,7 +165,7 @@ void OVERLAY_particle_cache_populate(OVERLAY_Data *vedata, Object *ob) if (!ELEM(draw_as, PART_DRAW_NOT, PART_DRAW_OB, PART_DRAW_GR)) { struct GPUBatch *geom = DRW_cache_particles_get_dots(ob, psys); - struct GPUBatch *shape = NULL; + struct GPUBatch *shape = nullptr; DRWShadingGroup *grp; /* TODO(fclem): Here would be a good place for preemptive culling. */ @@ -173,7 +173,7 @@ void OVERLAY_particle_cache_populate(OVERLAY_Data *vedata, Object *ob) /* NOTE(fclem): Is color even useful in our modern context? */ Material *ma = BKE_object_material_get_eval(ob, part->omat); float color[4] = {0.6f, 0.6f, 0.6f, part->draw_size}; - if (ma != NULL) { + if (ma != nullptr) { copy_v3_v3(color, &ma->r); } @@ -182,7 +182,7 @@ void OVERLAY_particle_cache_populate(OVERLAY_Data *vedata, Object *ob) case PART_DRAW_DOT: grp = DRW_shgroup_create_sub(pd->particle_dots_grp); DRW_shgroup_uniform_vec4_copy(grp, "color", color); - DRW_shgroup_call(grp, geom, NULL); + DRW_shgroup_call(grp, geom, nullptr); break; case PART_DRAW_AXIS: case PART_DRAW_CIRC: @@ -190,7 +190,7 @@ void OVERLAY_particle_cache_populate(OVERLAY_Data *vedata, Object *ob) grp = DRW_shgroup_create_sub(pd->particle_shapes_grp); DRW_shgroup_uniform_vec4_copy(grp, "color", color); shape = DRW_cache_particles_get_prim(draw_as); - DRW_shgroup_call_instances_with_attrs(grp, NULL, shape, geom); + DRW_shgroup_call_instances_with_attrs(grp, nullptr, shape, geom); break; } } diff --git a/source/blender/draw/engines/overlay/overlay_private.h b/source/blender/draw/engines/overlay/overlay_private.hh similarity index 100% rename from source/blender/draw/engines/overlay/overlay_private.h rename to source/blender/draw/engines/overlay/overlay_private.hh diff --git a/source/blender/draw/engines/overlay/overlay_sculpt.c b/source/blender/draw/engines/overlay/overlay_sculpt.cc similarity index 94% rename from source/blender/draw/engines/overlay/overlay_sculpt.c rename to source/blender/draw/engines/overlay/overlay_sculpt.cc index 4a6477b3f6c..ddad1f06537 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt.c +++ b/source/blender/draw/engines/overlay/overlay_sculpt.cc @@ -8,7 +8,7 @@ #include "DRW_render.h" #include "draw_cache_impl.h" -#include "overlay_private.h" +#include "overlay_private.hh" #include "BKE_paint.h" #include "BKE_pbvh.h" @@ -56,7 +56,7 @@ void OVERLAY_sculpt_cache_populate(OVERLAY_Data *vedata, Object *ob) DRW_shgroup_call_sculpt(pd->sculpt_mask_grp, ob, false, true); } else { - sculpt_overlays = DRW_mesh_batch_cache_get_sculpt_overlays(ob->data); + sculpt_overlays = DRW_mesh_batch_cache_get_sculpt_overlays(static_cast(ob->data)); if (sculpt_overlays) { DRW_shgroup_call(pd->sculpt_mask_grp, sculpt_overlays, ob); } diff --git a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc index b8021124f27..1bba2a366a5 100644 --- a/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc +++ b/source/blender/draw/engines/overlay/overlay_sculpt_curves.cc @@ -8,7 +8,7 @@ #include "DRW_render.h" #include "draw_cache_impl.h" -#include "overlay_private.h" +#include "overlay_private.hh" #include "BKE_curves.hh" diff --git a/source/blender/draw/engines/overlay/overlay_shader.c b/source/blender/draw/engines/overlay/overlay_shader.cc similarity index 99% rename from source/blender/draw/engines/overlay/overlay_shader.c rename to source/blender/draw/engines/overlay/overlay_shader.cc index 2373363ab9d..b0a6926a57f 100644 --- a/source/blender/draw/engines/overlay/overlay_shader.c +++ b/source/blender/draw/engines/overlay/overlay_shader.cc @@ -11,7 +11,7 @@ #include "UI_resources.h" -#include "overlay_private.h" +#include "overlay_private.hh" typedef struct OVERLAY_Shaders { GPUShader *antialiasing; @@ -106,7 +106,7 @@ typedef struct OVERLAY_Shaders { static struct { OVERLAY_Shaders sh_data[GPU_SHADER_CFG_LEN]; -} e_data = {{{NULL}}}; +} e_data = {{{nullptr}}}; GPUShader *OVERLAY_shader_antialiasing(void) { @@ -162,7 +162,7 @@ GPUShader *OVERLAY_shader_edit_mesh_edge(bool use_flat_interp) const DRWContextState *draw_ctx = DRW_context_state_get(); OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; GPUShader **sh = use_flat_interp ? &sh_data->edit_mesh_edge_flat : &sh_data->edit_mesh_edge; - if (*sh == NULL) { + if (*sh == nullptr) { *sh = GPU_shader_create_from_info_name( draw_ctx->sh_cfg ? (use_flat_interp ? "overlay_edit_mesh_edge_flat_clipped" : @@ -486,7 +486,7 @@ GPUShader *OVERLAY_shader_extra_wire(bool use_object, bool is_select) OVERLAY_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; GPUShader **sh = (is_select) ? &sh_data->extra_wire_select : &sh_data->extra_wire[use_object]; if (!*sh) { - const char *info_name = NULL; + const char *info_name = nullptr; if (draw_ctx->sh_cfg) { if (is_select) { info_name = "overlay_extra_wire_select_clipped"; @@ -996,7 +996,7 @@ GPUShader *OVERLAY_shader_edit_uv_tiled_image_borders_get(void) /** \} */ -static OVERLAY_InstanceFormats g_formats = {NULL}; +static OVERLAY_InstanceFormats g_formats = {nullptr}; OVERLAY_InstanceFormats *OVERLAY_shader_instance_formats_get(void) { diff --git a/source/blender/draw/engines/overlay/overlay_shader_shared.h b/source/blender/draw/engines/overlay/overlay_shader_shared.h index 339b6f02e1a..739e5be6c2f 100644 --- a/source/blender/draw/engines/overlay/overlay_shader_shared.h +++ b/source/blender/draw/engines/overlay/overlay_shader_shared.h @@ -38,6 +38,9 @@ enum OVERLAY_GridBits { PLANE_IMAGE = (1u << 11u), CUSTOM_GRID = (1u << 12u), }; +#ifndef GPU_SHADER +ENUM_OPERATORS(OVERLAY_GridBits, CUSTOM_GRID) +#endif /* Match: #SI_GRID_STEPS_LEN */ #define OVERLAY_GRID_STEPS_LEN 8 diff --git a/source/blender/draw/engines/overlay/overlay_volume.c b/source/blender/draw/engines/overlay/overlay_volume.cc similarity index 89% rename from source/blender/draw/engines/overlay/overlay_volume.c rename to source/blender/draw/engines/overlay/overlay_volume.cc index ee0d80734ab..daf76c394b3 100644 --- a/source/blender/draw/engines/overlay/overlay_volume.c +++ b/source/blender/draw/engines/overlay/overlay_volume.cc @@ -9,7 +9,7 @@ #include "DRW_render.h" #include "GPU_shader.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_volume_cache_init(OVERLAY_Data *vedata) { @@ -25,8 +25,8 @@ void OVERLAY_volume_cache_init(OVERLAY_Data *vedata) pd->volume_selection_surface_grp = grp; } else { - psl->volume_ps = NULL; - pd->volume_selection_surface_grp = NULL; + psl->volume_ps = nullptr; + pd->volume_selection_surface_grp = nullptr; } } @@ -37,7 +37,7 @@ void OVERLAY_volume_cache_populate(OVERLAY_Data *vedata, Object *ob) if (is_select) { struct GPUBatch *geom = DRW_cache_volume_selection_surface_get(ob); - if (geom != NULL) { + if (geom != nullptr) { DRW_shgroup_call(pd->volume_selection_surface_grp, geom, ob); } } diff --git a/source/blender/draw/engines/overlay/overlay_wireframe.c b/source/blender/draw/engines/overlay/overlay_wireframe.cc similarity index 94% rename from source/blender/draw/engines/overlay/overlay_wireframe.c rename to source/blender/draw/engines/overlay/overlay_wireframe.cc index a5628559cfd..edaa96651b2 100644 --- a/source/blender/draw/engines/overlay/overlay_wireframe.c +++ b/source/blender/draw/engines/overlay/overlay_wireframe.cc @@ -27,7 +27,7 @@ #include "ED_view3d.h" -#include "overlay_private.h" +#include "overlay_private.hh" void OVERLAY_wireframe_init(OVERLAY_Data *vedata) { @@ -43,7 +43,7 @@ void OVERLAY_wireframe_cache_init(OVERLAY_Data *vedata) OVERLAY_TextureList *txl = vedata->txl; OVERLAY_PrivateData *pd = vedata->stl->pd; const DRWContextState *draw_ctx = DRW_context_state_get(); - DRWShadingGroup *grp = NULL; + DRWShadingGroup *grp = nullptr; View3DShading *shading = &draw_ctx->v3d->shading; @@ -112,7 +112,7 @@ void OVERLAY_wireframe_cache_init(OVERLAY_Data *vedata) pd->wires_hair_grp[1][use_coloring] = pd->wires_hair_grp[0][use_coloring]; } pd->wires_sculpt_grp[1] = pd->wires_sculpt_grp[0]; - psl->wireframe_xray_ps = NULL; + psl->wireframe_xray_ps = nullptr; } } @@ -125,11 +125,11 @@ static void wireframe_hair_cache_populate(OVERLAY_Data *vedata, Object *ob, Part DupliObject *dupli_object = DRW_object_get_dupli(ob); float dupli_mat[4][4]; - if ((dupli_parent != NULL) && (dupli_object != NULL)) { + if ((dupli_parent != nullptr) && (dupli_object != nullptr)) { if (dupli_object->type & OB_DUPLICOLLECTION) { unit_m4(dupli_mat); Collection *collection = dupli_parent->instance_collection; - if (collection != NULL) { + if (collection != nullptr) { sub_v3_v3(dupli_mat[3], collection->instance_offset); } mul_m4_m4m4(dupli_mat, dupli_parent->obmat, dupli_mat); @@ -144,7 +144,7 @@ static void wireframe_hair_cache_populate(OVERLAY_Data *vedata, Object *ob, Part unit_m4(dupli_mat); } - struct GPUBatch *hairs = DRW_cache_particles_get_hair(ob, psys, NULL); + struct GPUBatch *hairs = DRW_cache_particles_get_hair(ob, psys, nullptr); const bool use_coloring = true; DRWShadingGroup *shgrp = DRW_shgroup_create_sub(pd->wires_hair_grp[is_xray][use_coloring]); @@ -167,7 +167,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, bool is_mesh_verts_only = false; if (is_mesh) { /* TODO: Should be its own function. */ - Mesh *me = ob->data; + Mesh *me = static_cast(ob->data); if (is_edit_mode) { BLI_assert(me->edit_mesh); Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(ob); @@ -184,7 +184,9 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, (ob->dtx & OB_DRAWWIRE) || (ob->dt == OB_WIRE)); if (use_wire && pd->wireframe_mode && ob->particlesystem.first) { - for (ParticleSystem *psys = ob->particlesystem.first; psys != NULL; psys = psys->next) { + for (ParticleSystem *psys = static_cast(ob->particlesystem.first); + psys != nullptr; + psys = psys->next) { if (!DRW_object_is_visible_psys_in_active_context(ob, psys)) { continue; } @@ -201,7 +203,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, float *color; DRW_object_wire_theme_get(ob, draw_ctx->view_layer, &color); - struct GPUBatch *geom = NULL; + struct GPUBatch *geom = nullptr; switch (ob->type) { case OB_CURVES_LEGACY: geom = DRW_cache_curve_edge_wire_get(ob); @@ -251,7 +253,7 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, bool draw_as_points = true; if (ob->type == OB_VOLUME) { /* Volume object as points exception. */ - Volume *volume = ob->data; + Volume *volume = static_cast(ob->data); draw_as_points = volume->display.wireframe_type == VOLUME_WIREFRAME_POINTS; } @@ -268,12 +270,12 @@ void OVERLAY_wireframe_cache_populate(OVERLAY_Data *vedata, } } - DRWShadingGroup *shgrp = NULL; - struct GPUBatch *geom = NULL; + DRWShadingGroup *shgrp = nullptr; + struct GPUBatch *geom = nullptr; /* Don't do that in edit Mesh mode, unless there is a modifier preview. */ if (use_wire && (!is_mesh || (!is_edit_mode || has_edit_mesh_cage))) { - const bool is_sculpt_mode = ((ob->mode & OB_MODE_SCULPT) != 0) && (ob->sculpt != NULL); + const bool is_sculpt_mode = ((ob->mode & OB_MODE_SCULPT) != 0) && (ob->sculpt != nullptr); const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) && !DRW_state_is_image_render(); const bool is_instance = (ob->base_flag & BASE_FROM_DUPLI); @@ -343,7 +345,7 @@ void OVERLAY_wireframe_draw(OVERLAY_Data *data) DRW_view_set_active(pd->view_wires); DRW_draw_pass(psl->wireframe_ps); - DRW_view_set_active(NULL); + DRW_view_set_active(nullptr); } void OVERLAY_wireframe_in_front_draw(OVERLAY_Data *data) @@ -355,6 +357,6 @@ void OVERLAY_wireframe_in_front_draw(OVERLAY_Data *data) DRW_view_set_active(pd->view_wires); DRW_draw_pass(psl->wireframe_xray_ps); - DRW_view_set_active(NULL); + DRW_view_set_active(nullptr); } } diff --git a/source/blender/draw/tests/shaders_test.cc b/source/blender/draw/tests/shaders_test.cc index e7baac63aae..dc631483857 100644 --- a/source/blender/draw/tests/shaders_test.cc +++ b/source/blender/draw/tests/shaders_test.cc @@ -17,7 +17,7 @@ #include "engines/eevee/eevee_private.h" #include "engines/gpencil/gpencil_engine.h" #include "engines/image/image_private.hh" -#include "engines/overlay/overlay_private.h" +#include "engines/overlay/overlay_private.hh" #include "engines/workbench/workbench_private.h" #include "intern/draw_shader.h"