2009-03-04 09:38:26 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BKE_utildefines.h"
|
|
|
|
|
|
|
|
|
|
#include "bmesh.h"
|
|
|
|
|
#include "mesh_intern.h"
|
|
|
|
|
#include "bmesh_private.h"
|
2009-11-23 14:41:22 +00:00
|
|
|
#include "BLI_math.h"
|
2009-09-17 23:05:33 +00:00
|
|
|
#include "BLI_array.h"
|
2009-03-04 09:38:26 +00:00
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2009-03-14 13:16:35 +00:00
|
|
|
#include <string.h>
|
2009-03-04 09:38:26 +00:00
|
|
|
|
|
|
|
|
#define VERT_INPUT 1
|
|
|
|
|
#define EDGE_OUT 1
|
2009-03-14 13:16:35 +00:00
|
|
|
#define FACE_NEW 2
|
2009-03-04 09:38:26 +00:00
|
|
|
|
|
|
|
|
void connectverts_exec(BMesh *bm, BMOperator *op)
|
|
|
|
|
{
|
|
|
|
|
BMIter iter, liter;
|
|
|
|
|
BMFace *f, *nf;
|
2009-03-14 13:16:35 +00:00
|
|
|
BMLoop **loops = NULL, *lastl = NULL;
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_declare(loops);
|
2009-03-13 13:11:50 +00:00
|
|
|
BMLoop *l, *nl;
|
2009-03-14 13:16:35 +00:00
|
|
|
BMVert *v1, *v2, **verts = NULL;
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_declare(verts);
|
2009-03-14 13:16:35 +00:00
|
|
|
int i;
|
2009-03-04 09:38:26 +00:00
|
|
|
|
Brought Extrude all the way back. The contextual menu works,
as does only edges and individual faces extrude (individual vert
extrude already did).
Note that I need to port this, after we all figure out how to handle
operators with variable transform follow-ons.
I also implemented the merge->collapse function, which is currently
accessable under ctrl->v, Bmesh Test Operator. I still need to
implement the other merge modes, and properly hook everything into
the merge menu tool, which I plan on doing soon (tomorrow hopefully).
The cool thing about the collapse tool, is not only does it handle (all)
UV layers, it handles vcols as well. To do this, I had to add a few math
functions to the customdata API, which seem to be working well.
2009-08-11 07:49:35 +00:00
|
|
|
BMO_Flag_Buffer(bm, op, "verts", VERT_INPUT, BM_VERT);
|
2009-03-04 09:38:26 +00:00
|
|
|
|
2009-03-22 23:16:43 +00:00
|
|
|
for (f=BMIter_New(&iter, bm, BM_FACES_OF_MESH, NULL); f; f=BMIter_Step(&iter)){
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_empty(loops);
|
|
|
|
|
BLI_array_empty(verts);
|
2009-03-14 13:16:35 +00:00
|
|
|
|
|
|
|
|
if (BMO_TestFlag(bm, f, FACE_NEW)) continue;
|
|
|
|
|
|
2009-03-04 09:38:26 +00:00
|
|
|
l = BMIter_New(&liter, bm, BM_LOOPS_OF_FACE, f);
|
|
|
|
|
v1 = v2 = NULL;
|
2009-03-14 13:16:35 +00:00
|
|
|
lastl = NULL;
|
2009-03-04 09:38:26 +00:00
|
|
|
for (; l; l=BMIter_Step(&liter)) {
|
|
|
|
|
if (BMO_TestFlag(bm, l->v, VERT_INPUT)) {
|
2009-03-14 13:16:35 +00:00
|
|
|
if (!lastl) {
|
|
|
|
|
lastl = l;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-14 22:06:10 +00:00
|
|
|
if (lastl != l->prev && lastl !=
|
|
|
|
|
l->next)
|
2009-03-14 13:16:35 +00:00
|
|
|
{
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_growone(loops);
|
|
|
|
|
loops[BLI_array_count(loops)-1] = lastl;
|
2009-03-14 13:16:35 +00:00
|
|
|
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_growone(loops);
|
|
|
|
|
loops[BLI_array_count(loops)-1] = l;
|
2009-03-14 13:16:35 +00:00
|
|
|
|
|
|
|
|
}
|
2009-03-15 06:14:03 +00:00
|
|
|
lastl = l;
|
2009-03-04 09:38:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-17 23:05:33 +00:00
|
|
|
if (BLI_array_count(loops) == 0) continue;
|
2009-03-14 13:16:35 +00:00
|
|
|
|
2009-09-17 23:05:33 +00:00
|
|
|
if (BLI_array_count(loops) > 2) {
|
|
|
|
|
BLI_array_growone(loops);
|
|
|
|
|
loops[BLI_array_count(loops)-1] = loops[BLI_array_count(loops)-2];
|
2009-03-14 13:16:35 +00:00
|
|
|
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_growone(loops);
|
|
|
|
|
loops[BLI_array_count(loops)-1] = loops[0];
|
2009-03-14 13:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-10 23:48:09 +00:00
|
|
|
BM_LegalSplits(bm, f, (BMLoop *(*)[2])loops, BLI_array_count(loops)/2);
|
2009-03-14 13:16:35 +00:00
|
|
|
|
2009-09-17 23:05:33 +00:00
|
|
|
for (i=0; i<BLI_array_count(loops)/2; i++) {
|
2009-03-14 13:16:35 +00:00
|
|
|
if (loops[i*2]==NULL) continue;
|
2009-03-13 13:11:50 +00:00
|
|
|
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_growone(verts);
|
|
|
|
|
verts[BLI_array_count(verts)-1] = loops[i*2]->v;
|
2009-03-14 13:16:35 +00:00
|
|
|
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_growone(verts);
|
|
|
|
|
verts[BLI_array_count(verts)-1] = loops[i*2+1]->v;
|
2009-03-14 13:16:35 +00:00
|
|
|
}
|
|
|
|
|
|
2009-09-17 23:05:33 +00:00
|
|
|
for (i=0; i<BLI_array_count(verts)/2; i++) {
|
2009-03-14 13:16:35 +00:00
|
|
|
nf = BM_Split_Face(bm, f, verts[i*2],
|
|
|
|
|
verts[i*2+1], &nl, NULL);
|
|
|
|
|
f = nf;
|
2009-03-13 13:11:50 +00:00
|
|
|
|
|
|
|
|
if (!nl || !nf) {
|
2009-03-04 09:38:26 +00:00
|
|
|
BMO_RaiseError(bm, op,
|
|
|
|
|
BMERR_CONNECTVERT_FAILED, NULL);
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_free(loops);
|
2009-03-14 13:16:35 +00:00
|
|
|
return;;;
|
2009-03-04 09:38:26 +00:00
|
|
|
}
|
2009-03-14 13:16:35 +00:00
|
|
|
BMO_SetFlag(bm, nf, FACE_NEW);
|
2009-03-13 13:11:50 +00:00
|
|
|
BMO_SetFlag(bm, nl->e, EDGE_OUT);
|
2009-03-04 09:38:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-03-22 23:16:43 +00:00
|
|
|
BMO_Flag_To_Slot(bm, op, "edgeout", EDGE_OUT, BM_EDGE);
|
2009-03-14 13:16:35 +00:00
|
|
|
|
2009-09-17 23:05:33 +00:00
|
|
|
BLI_array_free(loops);
|
|
|
|
|
BLI_array_free(verts);
|
2009-03-04 09:38:26 +00:00
|
|
|
}
|