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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 |
|
||||
|
||||
Reference in New Issue
Block a user