Fix T58407: Wire frames are not showing with subdivision surfaces

This commit is contained in:
Clément Foucault 2018-12-05 20:33:28 +01:00
parent efe769f3f0
commit 0424ee86f0
Notes: blender-bot 2023-02-14 11:21:43 +01:00
Referenced by issue #58407, Wire frames are not showing with subdivision surfaces
2 changed files with 39 additions and 4 deletions

View File

@ -4413,7 +4413,6 @@ static GPUTexture *mesh_batch_cache_get_edges_overlay_texture_buf(
{
BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI));
BLI_assert(rdata->edit_bmesh == NULL); /* Not supported in edit mode */
if (cache->edges_face_overlay_tx != NULL) {
return cache->edges_face_overlay_tx;
@ -5109,6 +5108,28 @@ void DRW_mesh_batch_cache_get_wireframes_face_texbuf(
if (cache->edges_face_overlay_tx == NULL || cache->pos_in_order_tx == NULL) {
const int options = MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI;
/* Hack to show the final result. */
BMesh *bm_mapped = NULL;
const int *p_origindex = NULL;
const bool use_em_final = (
me->edit_btmesh &&
me->edit_btmesh->mesh_eval_final &&
(me->edit_btmesh->mesh_eval_final->runtime.is_original == false));
Mesh me_fake;
if (use_em_final) {
/* Pass in mapped args. */
bm_mapped = me->edit_btmesh->bm;
p_origindex = CustomData_get_layer(&me->edit_btmesh->mesh_eval_final->pdata, CD_ORIGINDEX);
if (p_origindex == NULL) {
bm_mapped = NULL;
}
me_fake = *me->edit_btmesh->mesh_eval_final;
me_fake.mat = me->mat;
me_fake.totcol = me->totcol;
me = &me_fake;
}
MeshRenderData *rdata = mesh_render_data_create(me, options);
mesh_batch_cache_get_edges_overlay_texture_buf(rdata, cache, reduce_len);

View File

@ -23,8 +23,10 @@
* \ingroup draw_engine
*/
#include "DNA_mesh_types.h"
#include "DNA_view3d_types.h"
#include "BKE_editmesh.h"
#include "BKE_object.h"
#include "GPU_shader.h"
@ -251,8 +253,20 @@ static void overlay_cache_populate(void *vedata, Object *ob)
(ob->dtx & OB_DRAWWIRE) ||
(ob->dt == OB_WIRE))
{
/* Don't do that in edit Mesh mode. */
if (((ob != draw_ctx->object_edit) && !BKE_object_is_in_editmode(ob)) || ob->type != OB_MESH) {
bool has_edit_mesh_cage = false;
if (ob->type == OB_MESH) {
/* TODO: Should be its own function. */
Mesh *me = (Mesh *)ob->data;
BMEditMesh *embm = me->edit_btmesh;
if (embm) {
has_edit_mesh_cage = embm->mesh_eval_cage && (embm->mesh_eval_cage != embm->mesh_eval_final);
}
}
/* Don't do that in edit Mesh mode, unless there is a modifier preview. */
if ((((ob != draw_ctx->object_edit) && !BKE_object_is_in_editmode(ob)) || has_edit_mesh_cage) ||
ob->type != OB_MESH)
{
const bool is_active = (ob == draw_ctx->obact);
const bool is_sculpt_mode = is_active && (draw_ctx->object_mode & OB_MODE_SCULPT) != 0;
const bool all_wires = (stl->g_data->overlay.wireframe_threshold == 1.0f) ||
@ -295,7 +309,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
DRW_cache_object_face_wireframe_get(ob, &verts, &faceids, &tri_count, reduced_tri_len);
if (verts) {
float *rim_col = ts.colorWire;
if ((ob->base_flag & BASE_SELECTED) != 0) {
if (!has_edit_mesh_cage && ((ob->base_flag & BASE_SELECTED) != 0)) {
rim_col = (ob == draw_ctx->obact) ? ts.colorActive : ts.colorSelect;
}
DRWPass *pass = (all_wires) ? psl->face_wireframe_full_pass : psl->face_wireframe_pass;