diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-07-20 07:12:35 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-07-20 07:42:35 +0300 |
commit | e5e9fbfaf040140bbc152bcf9b013d01ae2884df (patch) | |
tree | 5e216e0275a622430023a10a8fbfb1dbb8e7a9d2 | |
parent | 86e6d6695e815746e877f9a4234f6805d5a4c155 (diff) |
Replace MFace use by MLoopTri w/ remash modifier
D1419 by @lichtwerk
-rw-r--r-- | intern/dualcon/dualcon.h | 16 | ||||
-rw-r--r-- | intern/dualcon/intern/dualcon_c_api.cpp | 68 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_remesh.c | 8 |
3 files changed, 38 insertions, 54 deletions
diff --git a/intern/dualcon/dualcon.h b/intern/dualcon/dualcon.h index c1452a72970..6ec63f4fdac 100644 --- a/intern/dualcon/dualcon.h +++ b/intern/dualcon/dualcon.h @@ -32,17 +32,25 @@ extern "C" { #endif typedef float (*DualConCo)[3]; -typedef unsigned int (*DualConFaces)[4]; + +typedef unsigned int (*DualConTri)[3]; + +typedef unsigned int (*DualConLoop); + struct DerivedMesh; typedef struct DualConInput { + DualConLoop mloop; + DualConCo co; int co_stride; int totco; - DualConFaces faces; - int face_stride; - int totface; + DualConTri looptri; + int tri_stride; + int tottri; + + int loop_stride; float min[3], max[3]; } DualConInput; diff --git a/intern/dualcon/intern/dualcon_c_api.cpp b/intern/dualcon/intern/dualcon_c_api.cpp index a6715394942..e55de2ed354 100644 --- a/intern/dualcon/intern/dualcon_c_api.cpp +++ b/intern/dualcon/intern/dualcon_c_api.cpp @@ -39,17 +39,20 @@ static void veccopy(float dst[3], const float src[3]) dst[2] = src[2]; } -#define GET_FACE(_mesh, _n) \ - (*(DualConFaces)(((char *)(_mesh)->faces) + ((_n) * (_mesh)->face_stride))) +#define GET_TRI(_mesh, _n) \ + (*(DualConTri)(((char *)(_mesh)->looptri) + ((_n) * (_mesh)->tri_stride))) #define GET_CO(_mesh, _n) \ (*(DualConCo)(((char *)(_mesh)->co) + ((_n) * (_mesh)->co_stride))) +#define GET_LOOP(_mesh, _n) \ + (*(DualConLoop)(((char *)(_mesh)->mloop) + ((_n) * (_mesh)->loop_stride))) + class DualConInputReader : public ModelReader { private: const DualConInput *input_mesh; -int tottri, curface, offset; +int tottri, curtri; float min[3], max[3], maxsize; float scale; public: @@ -61,14 +64,9 @@ DualConInputReader(const DualConInput *mesh, float _scale) void reset() { - tottri = 0; - curface = 0; - offset = 0; + curtri = 0; maxsize = 0; - - /* initialize tottri */ - for (int i = 0; i < input_mesh->totface; i++) - tottri += GET_FACE(input_mesh, i)[3] ? 2 : 1; + tottri = input_mesh->tottri; veccopy(min, input_mesh->min); veccopy(max, input_mesh->max); @@ -94,29 +92,17 @@ void reset() Triangle *getNextTriangle() { - if (curface == input_mesh->totface) - return 0; + if (curtri == input_mesh->tottri) + return NULL; Triangle *t = new Triangle(); - unsigned int *f = GET_FACE(input_mesh, curface); - if (offset == 0) { - veccopy(t->vt[0], GET_CO(input_mesh, f[0])); - veccopy(t->vt[1], GET_CO(input_mesh, f[1])); - veccopy(t->vt[2], GET_CO(input_mesh, f[2])); - } - else { - veccopy(t->vt[0], GET_CO(input_mesh, f[2])); - veccopy(t->vt[1], GET_CO(input_mesh, f[3])); - veccopy(t->vt[2], GET_CO(input_mesh, f[0])); - } + unsigned int *tr = GET_TRI(input_mesh, curtri); + veccopy(t->vt[0], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[0]))); + veccopy(t->vt[1], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[1]))); + veccopy(t->vt[2], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[2]))); - if (offset == 0 && f[3]) - offset++; - else { - offset = 0; - curface++; - } + curtri++; /* remove triangle if it contains invalid coords */ for (int i = 0; i < 3; i++) { @@ -132,27 +118,15 @@ Triangle *getNextTriangle() int getNextTriangle(int t[3]) { - if (curface == input_mesh->totface) + if (curtri == input_mesh->tottri) return 0; - unsigned int *f = GET_FACE(input_mesh, curface); - if (offset == 0) { - t[0] = f[0]; - t[1] = f[1]; - t[2] = f[2]; - } - else { - t[0] = f[2]; - t[1] = f[3]; - t[2] = f[0]; - } + unsigned int *tr = GET_TRI(input_mesh, curtri); + t[0] = tr[0]; + t[1] = tr[1]; + t[2] = tr[2]; - if (offset == 0 && f[3]) - offset++; - else { - offset = 0; - curface++; - } + curtri++; return 1; } diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c index 9df064db44d..79565655561 100644 --- a/source/blender/modifiers/intern/MOD_remesh.c +++ b/source/blender/modifiers/intern/MOD_remesh.c @@ -78,9 +78,11 @@ static void init_dualcon_mesh(DualConInput *mesh, DerivedMesh *dm) mesh->co_stride = sizeof(MVert); mesh->totco = dm->getNumVerts(dm); - mesh->faces = (void *)dm->getTessFaceArray(dm); - mesh->face_stride = sizeof(MFace); - mesh->totface = dm->getNumTessFaces(dm); + mesh->mloop = (void *)dm->getLoopArray(dm); + mesh->loop_stride = sizeof(MLoop); + mesh->looptri = (void *)dm->getLoopTriArray(dm); + mesh->tri_stride = sizeof(MLoopTri); + mesh->tottri = dm->getNumLoopTri(dm); INIT_MINMAX(mesh->min, mesh->max); dm->getMinMax(dm, mesh->min, mesh->max); |