diff options
Diffstat (limited to 'source/blender/draw/engines')
5 files changed, 36 insertions, 37 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 3b78d8718ef..2b8673e2f53 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -28,9 +28,8 @@ #include "BLI_rand.h" #include "BLI_string_utils.h" -#include "BKE_particle.h" #include "BKE_paint.h" -#include "BKE_pbvh.h" +#include "BKE_particle.h" #include "DNA_world_types.h" #include "DNA_modifier_types.h" @@ -1535,10 +1534,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, Scene *scene = draw_ctx->scene; GHash *material_hash = stl->g_data->material_hash; - bool is_sculpt_mode = DRW_object_use_pbvh_drawing(ob); - /* For now just force fully shaded with eevee when supported. */ - is_sculpt_mode = is_sculpt_mode && - !(ob->sculpt->pbvh && BKE_pbvh_type(ob->sculpt->pbvh) == PBVH_FACES); + bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d); /* First get materials for this mesh. */ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) { @@ -1606,7 +1602,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, int auto_layer_count; struct GPUBatch **mat_geom = NULL; - if (!is_sculpt_mode) { + if (!use_sculpt_pbvh) { mat_geom = DRW_cache_object_surface_material_get(ob, gpumat_array, materials_len, @@ -1615,7 +1611,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, &auto_layer_count); } - if (is_sculpt_mode) { + if (use_sculpt_pbvh) { /* Vcol is not supported in the modes that require PBVH drawing. */ bool use_vcol = false; DRW_shgroup_call_sculpt_with_materials(shgrp_array, ob, use_vcol); diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c index 516d4de897f..3dbdd1cce61 100644 --- a/source/blender/draw/engines/workbench/workbench_deferred.c +++ b/source/blender/draw/engines/workbench/workbench_deferred.c @@ -30,6 +30,7 @@ #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" #include "BKE_particle.h" #include "DNA_image_types.h" @@ -965,13 +966,13 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) WORKBENCH_MaterialData *material; if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) { const bool is_active = (ob == draw_ctx->obact); - const bool is_sculpt_mode = DRW_object_use_pbvh_drawing(ob); + const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d); const bool use_hide = is_active && DRW_object_use_hide_faces(ob); const int materials_len = MAX2(1, ob->totcol); const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL; bool has_transp_mat = false; - if (!is_sculpt_mode && TEXTURE_DRAWING_ENABLED(wpd) && me && me->mloopuv) { + if (!use_sculpt_pbvh && TEXTURE_DRAWING_ENABLED(wpd) && me && me->mloopuv) { /* Draw textured */ struct GPUBatch **geom_array = DRW_cache_mesh_surface_texpaint_get(ob); for (int i = 0; i < materials_len; i++) { @@ -981,12 +982,13 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) ImageUser *iuser; int interp; workbench_material_get_image_and_mat(ob, i + 1, &image, &iuser, &interp, &mat); - int color_type = workbench_material_determine_color_type(wpd, image, ob, is_sculpt_mode); + int color_type = workbench_material_determine_color_type( + wpd, image, ob, use_sculpt_pbvh); if (color_type == V3D_SHADING_MATERIAL_COLOR && mat && mat->a < 1.0) { /* Hack */ wpd->shading.xray_alpha = mat->a; material = workbench_forward_get_or_create_material_data( - vedata, ob, mat, image, iuser, color_type, 0, is_sculpt_mode); + vedata, ob, mat, image, iuser, color_type, 0, use_sculpt_pbvh); has_transp_mat = true; } else { @@ -1002,13 +1004,13 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) V3D_SHADING_OBJECT_COLOR, V3D_SHADING_RANDOM_COLOR, V3D_SHADING_VERTEX_COLOR)) { - int color_type = workbench_material_determine_color_type(wpd, NULL, ob, is_sculpt_mode); + int color_type = workbench_material_determine_color_type(wpd, NULL, ob, use_sculpt_pbvh); if ((ob->color[3] < 1.0f) && (color_type == V3D_SHADING_OBJECT_COLOR)) { /* Hack */ wpd->shading.xray_alpha = ob->color[3]; material = workbench_forward_get_or_create_material_data( - vedata, ob, NULL, NULL, NULL, color_type, 0, is_sculpt_mode); + vedata, ob, NULL, NULL, NULL, color_type, 0, use_sculpt_pbvh); has_transp_mat = true; } else { @@ -1016,7 +1018,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) material = get_or_create_material_data(vedata, ob, NULL, NULL, NULL, color_type, 0); } - if (is_sculpt_mode) { + if (use_sculpt_pbvh) { bool use_vcol = (color_type == V3D_SHADING_VERTEX_COLOR); DRW_shgroup_call_sculpt(material->shgrp, ob, false, false, use_vcol); } @@ -1036,7 +1038,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) } else { /* Draw material color */ - if (is_sculpt_mode) { + if (use_sculpt_pbvh) { struct DRWShadingGroup **shgrps = BLI_array_alloca(shgrps, materials_len); for (int i = 0; i < materials_len; ++i) { @@ -1045,7 +1047,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) /* Hack */ wpd->shading.xray_alpha = mat->a; material = workbench_forward_get_or_create_material_data( - vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, is_sculpt_mode); + vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, use_sculpt_pbvh); has_transp_mat = true; } else { @@ -1070,7 +1072,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) /* Hack */ wpd->shading.xray_alpha = mat->a; material = workbench_forward_get_or_create_material_data( - vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, is_sculpt_mode); + vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, use_sculpt_pbvh); has_transp_mat = true; } else { @@ -1087,7 +1089,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob) bool is_manifold; struct GPUBatch *geom_shadow = DRW_cache_object_edge_detection_get(ob, &is_manifold); if (geom_shadow) { - if (is_sculpt_mode || use_hide) { + if (use_sculpt_pbvh || use_hide) { /* Currently unsupported in sculpt mode. We could revert to the slow * method in this case but I'm not sure if it's a good idea given that * sculpted meshes are heavy to begin with. */ diff --git a/source/blender/draw/engines/workbench/workbench_forward.c b/source/blender/draw/engines/workbench/workbench_forward.c index 26c4b920382..eccf2b1a0f0 100644 --- a/source/blender/draw/engines/workbench/workbench_forward.c +++ b/source/blender/draw/engines/workbench/workbench_forward.c @@ -29,9 +29,10 @@ #include "BLI_string_utils.h" #include "BLI_utildefines.h" -#include "BKE_particle.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_paint.h" +#include "BKE_particle.h" #include "DNA_image_types.h" #include "DNA_mesh_types.h" @@ -141,7 +142,7 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_ ImageUser *iuser, int color_type, int interp, - bool is_sculpt_mode) + bool use_sculpt_pbvh) { const DRWContextState *draw_ctx = DRW_context_state_get(); WORKBENCH_FORWARD_Shaders *sh_data = &e_data.sh_data[draw_ctx->sh_cfg]; @@ -198,7 +199,7 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_ material->shgrp = grp; /* Depth */ - if (workbench_material_determine_color_type(wpd, material->ima, ob, is_sculpt_mode) == + if (workbench_material_determine_color_type(wpd, material->ima, ob, use_sculpt_pbvh) == V3D_SHADING_TEXTURE_COLOR) { material->shgrp_object_outline = DRW_shgroup_create(sh_data->object_outline_texture_sh, psl->object_outline_pass); @@ -567,11 +568,11 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) WORKBENCH_MaterialData *material; if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) { - const bool is_sculpt_mode = DRW_object_use_pbvh_drawing(ob); + const bool use_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d); const int materials_len = MAX2(1, ob->totcol); const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL; - if (!is_sculpt_mode && TEXTURE_DRAWING_ENABLED(wpd) && me && me->mloopuv) { + if (!use_sculpt_pbvh && TEXTURE_DRAWING_ENABLED(wpd) && me && me->mloopuv) { struct GPUBatch **geom_array = DRW_cache_mesh_surface_texpaint_get(ob); for (int i = 0; i < materials_len; i++) { Material *mat; @@ -579,9 +580,9 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) ImageUser *iuser; int interp; workbench_material_get_image_and_mat(ob, i + 1, &image, &iuser, &interp, &mat); - int color_type = workbench_material_determine_color_type(wpd, image, ob, is_sculpt_mode); + int color_type = workbench_material_determine_color_type(wpd, image, ob, use_sculpt_pbvh); material = workbench_forward_get_or_create_material_data( - vedata, ob, mat, image, iuser, color_type, interp, is_sculpt_mode); + vedata, ob, mat, image, iuser, color_type, interp, use_sculpt_pbvh); DRW_shgroup_call(material->shgrp_object_outline, geom_array[i], ob); DRW_shgroup_call(material->shgrp, geom_array[i], ob); } @@ -592,11 +593,11 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) V3D_SHADING_RANDOM_COLOR, V3D_SHADING_VERTEX_COLOR)) { /* No material split needed */ - int color_type = workbench_material_determine_color_type(wpd, NULL, ob, is_sculpt_mode); + int color_type = workbench_material_determine_color_type(wpd, NULL, ob, use_sculpt_pbvh); - if (is_sculpt_mode) { + if (use_sculpt_pbvh) { material = workbench_forward_get_or_create_material_data( - vedata, ob, NULL, NULL, NULL, color_type, 0, is_sculpt_mode); + vedata, ob, NULL, NULL, NULL, color_type, 0, use_sculpt_pbvh); bool use_vcol = (color_type == V3D_SHADING_VERTEX_COLOR); /* TODO(fclem) make this call optional */ DRW_shgroup_call_sculpt(material->shgrp_object_outline, ob, false, false, false); @@ -610,7 +611,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) DRW_cache_object_surface_get(ob); if (geom) { material = workbench_forward_get_or_create_material_data( - vedata, ob, NULL, NULL, NULL, color_type, 0, is_sculpt_mode); + vedata, ob, NULL, NULL, NULL, color_type, 0, use_sculpt_pbvh); /* TODO(fclem) make this call optional */ DRW_shgroup_call(material->shgrp_object_outline, geom, ob); if (!is_wire) { @@ -621,13 +622,13 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) } else { /* Draw material color */ - if (is_sculpt_mode) { + if (use_sculpt_pbvh) { struct DRWShadingGroup **shgrps = BLI_array_alloca(shgrps, materials_len); for (int i = 0; i < materials_len; ++i) { struct Material *mat = give_current_material(ob, i + 1); material = workbench_forward_get_or_create_material_data( - vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, is_sculpt_mode); + vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, use_sculpt_pbvh); shgrps[i] = material->shgrp; } /* TODO(fclem) make this call optional */ @@ -650,7 +651,7 @@ void workbench_forward_cache_populate(WORKBENCH_Data *vedata, Object *ob) Material *mat = give_current_material(ob, i + 1); material = workbench_forward_get_or_create_material_data( - vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, is_sculpt_mode); + vedata, ob, mat, NULL, NULL, V3D_SHADING_MATERIAL_COLOR, 0, use_sculpt_pbvh); /* TODO(fclem) make this call optional */ DRW_shgroup_call(material->shgrp_object_outline, mat_geom[i], ob); if (!is_wire) { diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index 02fbbe0b042..6ca55d48681 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -237,12 +237,12 @@ int workbench_material_get_accum_shader_index(WORKBENCH_PrivateData *wpd, int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *ima, Object *ob, - bool is_sculpt_mode) + bool use_sculpt_pbvh) { int color_type = wpd->shading.color_type; const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL; - if ((color_type == V3D_SHADING_TEXTURE_COLOR && (ima == NULL || is_sculpt_mode)) || + if ((color_type == V3D_SHADING_TEXTURE_COLOR && (ima == NULL || use_sculpt_pbvh)) || (ob->dt < OB_TEXTURE)) { color_type = V3D_SHADING_MATERIAL_COLOR; } diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index 240d06c1e79..34196c6aa04 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -383,7 +383,7 @@ WORKBENCH_MaterialData *workbench_forward_get_or_create_material_data(WORKBENCH_ ImageUser *iuser, int color_type, int interp, - bool is_sculpt_mode); + bool use_sculpt_pbvh); /* workbench_effect_aa.c */ void workbench_aa_create_pass(WORKBENCH_Data *vedata, GPUTexture **tx); @@ -416,7 +416,7 @@ void workbench_dof_draw_pass(WORKBENCH_Data *vedata); int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *ima, Object *ob, - bool is_sculpt_mode); + bool use_sculpt_pbvh); void workbench_material_get_image_and_mat( Object *ob, int mat_nr, Image **r_image, ImageUser **r_iuser, int *r_interp, Material **r_mat); char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, |