[Bf-blender-cvs] [e5e9fbf] master: Replace MFace use by MLoopTri w/ remash modifier

Campbell Barton noreply at git.blender.org
Mon Jul 20 06:50:17 CEST 2015


Commit: e5e9fbfaf040140bbc152bcf9b013d01ae2884df
Author: Campbell Barton
Date:   Mon Jul 20 14:12:35 2015 +1000
Branches: master
https://developer.blender.org/rBe5e9fbfaf040140bbc152bcf9b013d01ae2884df

Replace MFace use by MLoopTri w/ remash modifier

D1419 by @lichtwerk

===================================================================

M	intern/dualcon/dualcon.h
M	intern/dualcon/intern/dualcon_c_api.cpp
M	source/blender/modifiers/intern/MOD_remesh.c

===================================================================

diff --git a/intern/dualcon/dualcon.h b/intern/dualcon/dualcon.h
index c1452a7..6ec63f4 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 a671539..e55de2e 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 9df064d..7956565 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);




More information about the Bf-blender-cvs mailing list