DwM: Show face-mask overlay even with full-shading

Without this face selection would be used but invisible,
display this over fully shaded surface.
This commit is contained in:
Campbell Barton 2017-07-14 16:45:47 +10:00
parent 25dba156be
commit 661f5a24d1
4 changed files with 43 additions and 36 deletions

View File

@ -2836,9 +2836,7 @@ static void DRW_engines_enable(const Scene *scene, SceneLayer *sl)
if (DRW_state_draw_support()) {
DRW_engines_enable_from_object_mode();
if ((obact == NULL) || (DRW_object_is_mode_shade(obact) != false)) {
DRW_engines_enable_from_mode(mode);
}
DRW_engines_enable_from_mode(mode);
}
}

View File

@ -211,7 +211,7 @@ static void PAINT_TEXTURE_cache_init(void *vedata)
Object *ob = draw_ctx->obact;
if (ob && ob->type == OB_MESH) {
Scene *scene = draw_ctx->scene;
bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL);
const bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL);
const Mesh *me = ob->data;
stl->g_data->shgroup_image_array = MEM_mallocN(
@ -285,41 +285,44 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
/* Get geometry cache */
const Mesh *me = ob->data;
Scene *scene = draw_ctx->scene;
bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL);
const bool use_surface = DRW_object_is_mode_shade(ob) == true;
const bool use_material_slots = (scene->toolsettings->imapaint.mode == IMAGEPAINT_MODE_MATERIAL);
bool ok = false;
if (me->mloopuv != NULL) {
if (use_material_slots) {
struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
if ((me->totcol == 0) || (geom_array == NULL)) {
struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
ok = true;
if (use_surface) {
if (me->mloopuv != NULL) {
if (use_material_slots) {
struct Gwn_Batch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
if ((me->totcol == 0) || (geom_array == NULL)) {
struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
ok = true;
}
else {
for (int i = 0; i < me->totcol; i++) {
if (stl->g_data->shgroup_image_array[i]) {
DRW_shgroup_call_add(stl->g_data->shgroup_image_array[i], geom_array[i], ob->obmat);
}
else {
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom_array[i], ob->obmat);
}
ok = true;
}
}
}
else {
for (int i = 0; i < me->totcol; i++) {
if (stl->g_data->shgroup_image_array[i]) {
DRW_shgroup_call_add(stl->g_data->shgroup_image_array[i], geom_array[i], ob->obmat);
}
else {
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom_array[i], ob->obmat);
}
struct Gwn_Batch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
if (geom && stl->g_data->shgroup_image_array[0]) {
DRW_shgroup_call_add(stl->g_data->shgroup_image_array[0], geom, ob->obmat);
ok = true;
}
}
}
else {
struct Gwn_Batch *geom = DRW_cache_mesh_surface_texpaint_single_get(ob);
if (geom && stl->g_data->shgroup_image_array[0]) {
DRW_shgroup_call_add(stl->g_data->shgroup_image_array[0], geom, ob->obmat);
ok = true;
}
}
}
if (!ok) {
struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
if (!ok) {
struct Gwn_Batch *geom = DRW_cache_mesh_surface_get(ob);
DRW_shgroup_call_add(stl->g_data->shgroup_fallback, geom, ob->obmat);
}
}
/* Face Mask */

View File

@ -144,15 +144,18 @@ static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob)
if ((ob->type == OB_MESH) && (ob == draw_ctx->obact)) {
IDProperty *ces_mode_pw = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_PAINT_VERTEX, "");
bool use_wire = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_wire");
const Mesh *me = ob->data;
const bool use_wire = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_wire");
const bool use_surface = DRW_object_is_mode_shade(ob) == true;
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
struct Gwn_Batch *geom;
world_light = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_shading") ? 0.5f : 1.0f;
geom = DRW_cache_mesh_surface_vert_colors_get(ob);
DRW_shgroup_call_add(stl->g_data->fvcolor_shgrp, geom, ob->obmat);
if (use_surface) {
geom = DRW_cache_mesh_surface_vert_colors_get(ob);
DRW_shgroup_call_add(stl->g_data->fvcolor_shgrp, geom, ob->obmat);
}
if (use_face_sel || use_wire) {
geom = DRW_cache_mesh_edges_paint_overlay_get(ob, use_wire, use_face_sel);

View File

@ -180,16 +180,19 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob)
if ((ob->type == OB_MESH) && (ob == draw_ctx->obact)) {
IDProperty *ces_mode_pw = BKE_layer_collection_engine_evaluated_get(ob, COLLECTION_MODE_PAINT_WEIGHT, "");
bool use_wire = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_wire");
const Mesh *me = ob->data;
const bool use_wire = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_wire");
const bool use_surface = DRW_object_is_mode_shade(ob) == true;
const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0;
const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0;
struct Gwn_Batch *geom;
world_light = BKE_collection_engine_property_value_get_bool(ces_mode_pw, "use_shading") ? 0.5f : 1.0f;
geom = DRW_cache_mesh_surface_weights_get(ob);
DRW_shgroup_call_add(stl->g_data->fweights_shgrp, geom, ob->obmat);
if (use_surface) {
geom = DRW_cache_mesh_surface_weights_get(ob);
DRW_shgroup_call_add(stl->g_data->fweights_shgrp, geom, ob->obmat);
}
if (use_face_sel || use_wire) {
geom = DRW_cache_mesh_edges_paint_overlay_get(ob, use_wire, use_face_sel);