Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/workbench/workbench_engine.c
| Show All 22 Lines | |||||
| * | * | ||||
| * Optimized engine to draw the working viewport with solid and transparent geometry. | * Optimized engine to draw the working viewport with solid and transparent geometry. | ||||
| */ | */ | ||||
| #include "DRW_render.h" | #include "DRW_render.h" | ||||
| #include "BLI_alloca.h" | #include "BLI_alloca.h" | ||||
| #include "BKE_editmesh.h" | |||||
| #include "BKE_modifier.h" | #include "BKE_modifier.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_particle.h" | #include "BKE_particle.h" | ||||
| #include "DNA_fluid_types.h" | #include "DNA_fluid_types.h" | ||||
| #include "DNA_hair_types.h" | #include "DNA_hair_types.h" | ||||
| #include "DNA_image_types.h" | #include "DNA_image_types.h" | ||||
| ▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | static void workbench_cache_hair_populate(WORKBENCH_PrivateData *wpd, | ||||
| state |= (imapaint && imapaint->interp == IMAGEPAINT_INTERP_LINEAR) ? GPU_SAMPLER_FILTER : 0; | state |= (imapaint && imapaint->interp == IMAGEPAINT_INTERP_LINEAR) ? GPU_SAMPLER_FILTER : 0; | ||||
| DRWShadingGroup *grp = (use_texpaint_mode) ? | DRWShadingGroup *grp = (use_texpaint_mode) ? | ||||
| workbench_image_hair_setup(wpd, ob, matnr, ima, NULL, state) : | workbench_image_hair_setup(wpd, ob, matnr, ima, NULL, state) : | ||||
| workbench_material_hair_setup(wpd, ob, matnr, color_type); | workbench_material_hair_setup(wpd, ob, matnr, color_type); | ||||
| DRW_shgroup_hair_create_sub(ob, psys, md, grp, NULL); | DRW_shgroup_hair_create_sub(ob, psys, md, grp, NULL); | ||||
| } | } | ||||
| static const CustomData *workbench_mesh_get_loop_custom_data(const Mesh *mesh) | |||||
| { | |||||
| if (mesh->runtime.wrapper_type == ME_WRAPPER_TYPE_BMESH) { | |||||
| BLI_assert(mesh->edit_mesh != NULL); | |||||
| BLI_assert(mesh->edit_mesh->bm != NULL); | |||||
| return &mesh->edit_mesh->bm->ldata; | |||||
| } | |||||
| return &mesh->ldata; | |||||
| } | |||||
| static const CustomData *workbench_mesh_get_vert_custom_data(const Mesh *mesh) | |||||
| { | |||||
| if (mesh->runtime.wrapper_type == ME_WRAPPER_TYPE_BMESH) { | |||||
| BLI_assert(mesh->edit_mesh != NULL); | |||||
| BLI_assert(mesh->edit_mesh->bm != NULL); | |||||
| return &mesh->edit_mesh->bm->vdata; | |||||
| } | |||||
| return &mesh->vdata; | |||||
| } | |||||
| /** | /** | ||||
| * Decide what color-type to draw the object with. | * Decide what color-type to draw the object with. | ||||
| * In some cases it can be overwritten by #workbench_material_setup(). | * In some cases it can be overwritten by #workbench_material_setup(). | ||||
| */ | */ | ||||
| static eV3DShadingColorType workbench_color_type_get(WORKBENCH_PrivateData *wpd, | static eV3DShadingColorType workbench_color_type_get(WORKBENCH_PrivateData *wpd, | ||||
| Object *ob, | Object *ob, | ||||
| bool *r_sculpt_pbvh, | bool *r_sculpt_pbvh, | ||||
| bool *r_texpaint_mode, | bool *r_texpaint_mode, | ||||
| bool *r_draw_shadow) | bool *r_draw_shadow) | ||||
| { | { | ||||
| eV3DShadingColorType color_type = wpd->shading.color_type; | eV3DShadingColorType color_type = wpd->shading.color_type; | ||||
| const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL; | const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL; | ||||
| const CustomData *ldata = workbench_mesh_get_loop_custom_data(me); | |||||
| const CustomData *vdata = workbench_mesh_get_vert_custom_data(me); | |||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const bool is_active = (ob == draw_ctx->obact); | const bool is_active = (ob == draw_ctx->obact); | ||||
| const bool is_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) && | const bool is_sculpt_pbvh = BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) && | ||||
| !DRW_state_is_image_render(); | !DRW_state_is_image_render(); | ||||
| const bool is_render = DRW_state_is_image_render() && (draw_ctx->v3d == NULL); | const bool is_render = DRW_state_is_image_render() && (draw_ctx->v3d == NULL); | ||||
| const bool is_texpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_TEXTURE); | const bool is_texpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_TEXTURE); | ||||
| const bool is_vertpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_VERTEX); | const bool is_vertpaint_mode = is_active && (wpd->ctx_mode == CTX_MODE_PAINT_VERTEX); | ||||
| if (color_type == V3D_SHADING_TEXTURE_COLOR) { | if (color_type == V3D_SHADING_TEXTURE_COLOR) { | ||||
| if (ob->dt < OB_TEXTURE) { | if (ob->dt < OB_TEXTURE) { | ||||
| color_type = V3D_SHADING_MATERIAL_COLOR; | color_type = V3D_SHADING_MATERIAL_COLOR; | ||||
| } | } | ||||
| else if ((me == NULL) || (me->mloopuv == NULL)) { | else if ((me == NULL) || !CustomData_has_layer(ldata, CD_MLOOPUV)) { | ||||
| /* Disable color mode if data layer is unavailable. */ | /* Disable color mode if data layer is unavailable. */ | ||||
| color_type = V3D_SHADING_MATERIAL_COLOR; | color_type = V3D_SHADING_MATERIAL_COLOR; | ||||
| } | } | ||||
| } | } | ||||
| else if (color_type == V3D_SHADING_VERTEX_COLOR) { | else if (color_type == V3D_SHADING_VERTEX_COLOR) { | ||||
| if (U.experimental.use_sculpt_vertex_colors) { | if (U.experimental.use_sculpt_vertex_colors) { | ||||
| if ((me == NULL) || !CustomData_has_layer(&me->vdata, CD_PROP_COLOR)) { | if ((me == NULL) || !CustomData_has_layer(vdata, CD_PROP_COLOR)) { | ||||
| color_type = V3D_SHADING_OBJECT_COLOR; | color_type = V3D_SHADING_OBJECT_COLOR; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if ((me == NULL) || !CustomData_has_layer(&me->ldata, CD_MLOOPCOL)) { | if ((me == NULL) || !CustomData_has_layer(ldata, CD_MLOOPCOL)) { | ||||
| color_type = V3D_SHADING_OBJECT_COLOR; | color_type = V3D_SHADING_OBJECT_COLOR; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (r_sculpt_pbvh) { | if (r_sculpt_pbvh) { | ||||
| *r_sculpt_pbvh = is_sculpt_pbvh; | *r_sculpt_pbvh = is_sculpt_pbvh; | ||||
| } | } | ||||
| if (r_texpaint_mode) { | if (r_texpaint_mode) { | ||||
| *r_texpaint_mode = false; | *r_texpaint_mode = false; | ||||
| } | } | ||||
| if (!is_sculpt_pbvh && !is_render) { | if (!is_sculpt_pbvh && !is_render) { | ||||
| /* Force texture or vertex mode if object is in paint mode. */ | /* Force texture or vertex mode if object is in paint mode. */ | ||||
| if (is_texpaint_mode && me && me->mloopuv) { | if (is_texpaint_mode && me && CustomData_has_layer(ldata, CD_MLOOPUV)) { | ||||
| color_type = V3D_SHADING_TEXTURE_COLOR; | color_type = V3D_SHADING_TEXTURE_COLOR; | ||||
| if (r_texpaint_mode) { | if (r_texpaint_mode) { | ||||
| *r_texpaint_mode = true; | *r_texpaint_mode = true; | ||||
| } | } | ||||
| } | } | ||||
| else if (is_vertpaint_mode && me && me->mloopcol) { | else if (is_vertpaint_mode && me && CustomData_has_layer(ldata, CD_MLOOPCOL)) { | ||||
| color_type = V3D_SHADING_VERTEX_COLOR; | color_type = V3D_SHADING_VERTEX_COLOR; | ||||
| } | } | ||||
| } | } | ||||
| if (is_sculpt_pbvh && color_type == V3D_SHADING_TEXTURE_COLOR) { | if (is_sculpt_pbvh && color_type == V3D_SHADING_TEXTURE_COLOR) { | ||||
| /* Force use of material color for sculpt. */ | /* Force use of material color for sculpt. */ | ||||
| color_type = V3D_SHADING_MATERIAL_COLOR; | color_type = V3D_SHADING_MATERIAL_COLOR; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 350 Lines • Show Last 20 Lines | |||||