diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-10-08 09:29:59 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-10-08 09:31:32 +0300 |
commit | 772c4d6313ad842bbdfe101267f0bd34186e8a6f (patch) | |
tree | 10dc427c3368d0152c9fd7fea30e463665387cd6 | |
parent | 215c23590aa7ea0cbb113d75c32ccf57ffee3fd3 (diff) |
Edit Mesh: basic show in edit mode support
Note this is just using the derived-mesh data at the moment,
to support this properly we'll need to remove derived-mesh.
-rw-r--r-- | source/blender/blenkernel/BKE_cdderivedmesh.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/cdderivedmesh.c | 26 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 14 |
3 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h index 6d96bd6ab7c..b31a3548a1e 100644 --- a/source/blender/blenkernel/BKE_cdderivedmesh.h +++ b/source/blender/blenkernel/BKE_cdderivedmesh.h @@ -178,4 +178,6 @@ void CDDM_set_mface(struct DerivedMesh *dm, struct MFace *mface); void CDDM_set_mloop(struct DerivedMesh *dm, struct MLoop *mloop); void CDDM_set_mpoly(struct DerivedMesh *dm, struct MPoly *mpoly); +void CDDM_to_mesh__fast_borrow(struct DerivedMesh *dm, struct Mesh *me, const struct Mesh *me_reference); + #endif diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 9043460562d..83424da3a3d 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -2258,3 +2258,29 @@ void CDDM_set_mpoly(DerivedMesh *dm, MPoly *mpoly) cddm->mpoly = mpoly; } + +/** Hack to fill in an empty (non library mesh struct) with CDDM values. */ +void CDDM_to_mesh__fast_borrow(DerivedMesh *dm, Mesh *me, const Mesh *me_reference) +{ + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; + me->totvert = cddm->dm.numVertData; + me->totedge = cddm->dm.numEdgeData; + me->totloop = cddm->dm.numLoopData; + me->totpoly = cddm->dm.numPolyData; + + me->mvert = cddm->mvert; + me->medge = cddm->medge; + me->mface = cddm->mface; + me->mloop = cddm->mloop; + me->mpoly = cddm->mpoly; + + me->vdata = dm->vertData; + me->edata = dm->edgeData; + me->ldata = dm->loopData; + me->pdata = dm->polyData; + + if (me_reference) { + me->mat = me_reference->mat; + me->totcol = me_reference->totcol; + } +} diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 4fe7a32a824..e1787c2650b 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -53,6 +53,7 @@ #include "BKE_mesh.h" #include "BKE_mesh_tangent.h" #include "BKE_colorband.h" +#include "BKE_cdderivedmesh.h" #include "bmesh.h" @@ -4459,6 +4460,19 @@ GPUBatch **DRW_mesh_batch_cache_get_surface_shaded( MeshBatchCache *cache = mesh_batch_cache_get(me); if (cache->shaded_triangles == NULL) { + + /* Hack to show the final result. */ + const bool use_em_final = ( + me->edit_btmesh && + me->edit_btmesh->derivedFinal && + (me->edit_btmesh->derivedFinal->type == DM_TYPE_CDDM)); + Mesh me_fake; + if (use_em_final) { + memset(&me_fake, 0x0, sizeof(me_fake)); + CDDM_to_mesh__fast_borrow(me->edit_btmesh->derivedFinal, &me_fake, me); + me = &me_fake; + } + /* create batch from DM */ const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOP | MR_DATATYPE_LOOPTRI | |